{"record":{"id":"20e13b4509ee143c","repo":"apache/hadoop","slug":"bytes-per-checksum-must-be-greater-than-0","errorCode":null,"errorMessage":"Bytes per checksum must be greater than 0","messagePattern":"Bytes per checksum must be greater than 0","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java","lineNumber":116,"sourceCode":"    \n    public static class BufferSize extends CreateOpts {\n      private final int bufferSize;\n      protected BufferSize(int bs) {\n        if (bs <= 0) {\n          throw new IllegalArgumentException(\n                        \"Buffer size must be greater than 0\");\n        }\n        bufferSize = bs; \n      }\n      public int getValue() { return bufferSize; }\n    }\n\n    /** This is not needed if ChecksumParam is specified. **/\n    public static class BytesPerChecksum extends CreateOpts {\n      private final int bytesPerChecksum;\n      protected BytesPerChecksum(short bpc) { \n        if (bpc <= 0) {\n          throw new IllegalArgumentException(\n                        \"Bytes per checksum must be greater than 0\");\n        }\n        bytesPerChecksum = bpc; \n      }\n      public int getValue() { return bytesPerChecksum; }\n    }\n\n    public static class ChecksumParam extends CreateOpts {\n      private final ChecksumOpt checksumOpt;\n      protected ChecksumParam(ChecksumOpt csumOpt) {\n        checksumOpt = csumOpt;\n      }\n      public ChecksumOpt getValue() { return checksumOpt; }\n    }\n    \n    public static class Perms extends CreateOpts {\n      private final FsPermission permissions;\n      protected Perms(FsPermission perm) { ","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java#L98-L134","documentation":"Options.CreateOpts.BytesPerChecksum validates that bytesPerChecksum (a short) used with FileSystem.create(path, CreateOpts.bytesPerChecksum(bpc), ...) is positive; bpc <= 0 throws IllegalArgumentException at construction.","triggerScenarios":"CreateOpts.bytesPerChecksum(n) with n <= 0 — e.g. io.bytes.per.checksum set to 0, or code forwarding a defaulted/zeroed value into the option.","commonSituations":"Checksum config disabled by setting 0, mixed old/new config files after upgrades, unvalidated computed values.","solutions":["Set bytesPerChecksum to a positive value (HDFS default is 512)","Omit the BytesPerChecksum option and supply a ChecksumOpt instead when unsure","Validate bpc > 0 before constructing the option"],"exampleFix":"// before\nCreateOpts.bytesPerChecksum((short) 0)\n// after\nCreateOpts.bytesPerChecksum((short) 512)   // > 0, matching io.bytes.per.checksum default","handlingStrategy":"validation","validationCode":"short bpc = (short) conf.getInt(\"io.bytes.per.checksum\", 512);\nif (bpc <= 0) throw new IllegalArgumentException(\"bytes per checksum must be > 0\");\nfs.create(out, CreateOpts.bytesPerChecksum(bpc));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep bytes-per-checksum positive (HDFS default 512)","Prefer a ChecksumOpt option when checksum config is uncertain","Validate short casts from config before building options"],"tags":["create-options","checksum","illegal-argument","validation"],"backgroundTag":"invalid-bytes-per-checksum","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}