{"record":{"id":"e21db39b9c720101","repo":"testcontainers/testcontainers-java","slug":"provide-implementation-in-subclass","errorCode":null,"errorMessage":"Provide implementation in subclass","messagePattern":"Provide implementation in subclass","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/testcontainers/images/builder/Transferable.java","lineNumber":98,"sourceCode":"        try {\n            tarArchiveOutputStream.putArchiveEntry(tarEntry);\n            IOUtils.write(getBytes(), tarArchiveOutputStream);\n            tarArchiveOutputStream.closeArchiveEntry();\n        } catch (IOException e) {\n            throw new RuntimeException(\"Can't transfer \" + getDescription(), e);\n        }\n    }\n\n    default byte[] getBytes() {\n        return new byte[0];\n    }\n\n    default String getDescription() {\n        return \"\";\n    }\n\n    default void updateChecksum(Checksum checksum) {\n        throw new UnsupportedOperationException(\"Provide implementation in subclass\");\n    }\n}\n","sourceCodeStart":80,"sourceCodeEnd":101,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/images/builder/Transferable.java#L80-L101","documentation":"Transferable's default updateChecksum(Checksum) throws UnsupportedOperationException('Provide implementation in subclass') because checksumming is only meaningful for Transferables that actually carry content. Calling it on a base/default implementation (e.g. an empty Transferable or a custom one that didn't override it) hits this stub.","triggerScenarios":"Invoking updateChecksum() on a Transferable that does not override it — e.g. a custom Transferable implementation missing the override, or framework code computing a checksum over a contentless default Transferable.","commonSituations":"Writing a custom Transferable for ImageFromDockerfile and forgetting to override updateChecksum; new framework code path that checksums all Transferables including defaults.","solutions":["Override updateChecksum(Checksum) in your Transferable subclass and feed it the content bytes","If your Transferable has no content, override it as a no-op instead of relying on the default","Extend from MountableFile or an existing implementation that already implements checksums","Check for a library upgrade where your Transferable type implements updateChecksum"],"exampleFix":"// before\nclass MyFile implements Transferable { /* no updateChecksum */ }\n// after\nclass MyFile implements Transferable {\n    @Override\n    public void updateChecksum(Checksum checksum) {\n        checksum.update(getBytes(), 0, getBytes().length);\n    }\n}","handlingStrategy":"type-guard","validationCode":"// check the implementation actually supports checksumming\nstatic boolean supportsChecksum(Transferable t) {\n    try { t.updateChecksum(new java.util.zip.CRC32()); return true; }\n    catch (UnsupportedOperationException e) { return false; }\n}","typeGuard":"// narrow to implementations known to override updateChecksum\nif (transferable instanceof MountableFile) {\n    ((MountableFile) transferable).updateChecksum(checksum);\n}","tryCatchPattern":"try {\n    transferable.updateChecksum(checksum);\n} catch (UnsupportedOperationException e) {\n    // fall back to identity/skip checksum for contentless transferables\n    logger.warn(\"Transferable {} does not support checksums\", transferable.getDescription());\n}","preventionTips":["When implementing Transferable, always override updateChecksum and getBytes","Use abstract base classes that force the override instead of raw interface implementation","Add a unit test that checksums every custom Transferable you ship","Prefer extending MountableFile over implementing Transferable from scratch"],"tags":["unsupported-operation","checksum","transferable"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}