From dbed4fe7ae7f22e110e6623d93e15e780277619c Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 4 Oct 2026 15:22:29 +0100 Subject: [PATCH] avoid implicit narrowing compound assignments in SchemaTypeSystemImpl.nextBytes Fixes code-scanning alerts for java/implicit-cast-in-compound-assignment. Also mix the system-info bytes (not just their index) into the mask, and index the mask with % rather than & so all mask bytes are used. Co-Authored-By: Claude Opus 5.5 --- .../apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java index 8cad40154..0c7585e51 100644 --- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java +++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java @@ -595,8 +595,7 @@ private static synchronized void nextBytes(byte[] result) { byte[] bytes = baos.toByteArray(); for (int i = 0; i < bytes.length; i++) { int j = i % _mask.length; - _mask[j] *= (byte) 21; - _mask[j] += (byte) i; + _mask[j] = (byte) (_mask[j] * 21 + bytes[i]); } } catch (IOException e) { XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage()); @@ -606,7 +605,7 @@ private static synchronized void nextBytes(byte[] result) { } _random.nextBytes(result); for (int i = 0; i < result.length; i++) { - int j = i & _mask.length; + int j = i % _mask.length; result[i] ^= _mask[j]; } }