{"record":{"id":"04e32469d112d1e4","repo":"apache/beam","slug":"read-only-filesystem","errorCode":null,"errorMessage":"Read-only filesystem.","messagePattern":"Read-only filesystem\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/ClassLoaderFileSystem.java","lineNumber":58,"sourceCode":"@SuppressWarnings({\n  \"nullness\" // TODO(https://github.com/apache/beam/issues/20497)\n})\npublic class ClassLoaderFileSystem extends FileSystem<ClassLoaderFileSystem.ClassLoaderResourceId> {\n\n  public static final String SCHEMA = \"classpath\";\n  private static final String PREFIX = SCHEMA + \"://\";\n\n  ClassLoaderFileSystem() {}\n\n  @Override\n  protected List<MatchResult> match(List<String> specs) throws IOException {\n    throw new UnsupportedOperationException(\"Un-globbable filesystem.\");\n  }\n\n  @Override\n  protected WritableByteChannel create(\n      ClassLoaderResourceId resourceId, CreateOptions createOptions) throws IOException {\n    throw new UnsupportedOperationException(\"Read-only filesystem.\");\n  }\n\n  @Override\n  protected ReadableByteChannel open(ClassLoaderResourceId resourceId) throws IOException {\n    ClassLoader classLoader = getClass().getClassLoader();\n    InputStream inputStream =\n        classLoader.getResourceAsStream(resourceId.path.substring(PREFIX.length()));\n    if (inputStream == null) {\n\n      throw new IOException(\n          \"Unable to load \"\n              + resourceId.path\n              + \" with \"\n              + classLoader\n              + \" URL \"\n              + classLoader.getResource(resourceId.path.substring(PREFIX.length())));\n    }\n    return Channels.newChannel(inputStream);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/ClassLoaderFileSystem.java#L40-L76","documentation":"ClassLoaderFileSystem is a read-only filesystem backed by classloader resources; create() (any write operation) has no meaningful implementation and always throws UnsupportedOperationException('Read-only filesystem.').","triggerScenarios":"Calling FileSystems.create with a classpath:// resource id, directly or via WriteFiles/TextIO.write to a classpath destination.","commonSituations":"Pipelines configured with output paths on the classpath schema; users assuming classpath resources are writable; accidental use of classpath URIs in a write sink.","solutions":["Write to a real filesystem (local path, GCS, S3) instead of classpath://","If data must ship with the app, write to a temp/working directory at runtime and keep only static reads on the classpath","Check sink configuration so the output scheme is not classpath://","For packaging artifacts, place resources at build time rather than writing at runtime"],"exampleFix":"// before\nFileSystems.create(classpathResourceId, CreateOptions.defaults()); // throws\n// after\nResourceId out = FileSystems.matchNewResource(\"/tmp/output.txt\", false);\nWritableByteChannel ch = FileSystems.create(out, CreateOptions.defaults());","handlingStrategy":"try-catch","validationCode":"if (\"classpath\".equals(resourceId.getSchema())) {\n  throw new IllegalArgumentException(\"classpath filesystem is read-only\");\n}","typeGuard":"static boolean isWritableDestination(ResourceId id) {\n  return !\"classpath\".equals(id.getSchema());\n}","tryCatchPattern":"try {\n  return FileSystems.create(resourceId, options);\n} catch (UnsupportedOperationException e) {\n  // redirect to a writable filesystem\n}","preventionTips":["Never configure sinks with classpath:// destinations","Validate output schemas at pipeline construction time","Treat the classpath filesystem strictly as a read-only source"],"tags":["java","io","filesystem","read-only","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}