Skip to content

Commit d881a49

Browse files
oschwaldclaude
andcommitted
Use Integer.MIN_VALUE in coerceFromLong range check
Make the Integer range check consistent with Short and Byte conversions by using Integer.MIN_VALUE instead of checking for < 0. This ensures all narrowing conversions follow the same pattern and correctly handle the full range of Integer values. Addresses PR feedback in #309. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 5f3ac3b commit d881a49

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/maxmind/db/Decoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private static Object coerceFromLong(long value, Class<?> target) {
290290
return value;
291291
}
292292
if (target.equals(Integer.TYPE) || target.equals(Integer.class)) {
293-
if (value < 0 || value > Integer.MAX_VALUE) {
293+
if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
294294
throw new DeserializationException("Value " + value + " out of range for int");
295295
}
296296
return (int) value;

0 commit comments

Comments
 (0)