File tree Expand file tree Collapse file tree 4 files changed +16
-8
lines changed
main/java/com/iab/gpp/encoder/datatype/encoder
test/java/com/iab/gpp/encoder/datatype/encoder Expand file tree Collapse file tree 4 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 33import java .util .ArrayList ;
44import java .util .Collections ;
55import java .util .List ;
6+ import java .util .logging .Logger ;
67import java .util .regex .Pattern ;
78import com .iab .gpp .encoder .error .DecodingException ;
89
910public class FibonacciIntegerRangeEncoder {
1011
12+ private static final Logger LOGGER = Logger .getLogger (FibonacciIntegerRangeEncoder .class .getName ());
1113 // NOTE: This is a value roughly the 2x the size of this list
1214 // https://tools.iabtechlab.com/transparencycenter/explorer/business/gpp
1315 static final int MAX_SIZE = 8192 ;
@@ -74,7 +76,8 @@ public static List<Integer> decode(String bitString) throws DecodingException {
7476 startIndex = index + 2 ;
7577
7678 if (value .size () + (end - start ) > MAX_SIZE ) {
77- throw new DecodingException ("FibonacciIntegerRange has too many values" );
79+ LOGGER .warning ("FibonacciIntegerRange has too many values" );
80+ break ;
7881 }
7982 for (int j = start ; j <= end ; j ++) {
8083 value .add (j );
@@ -84,7 +87,8 @@ public static List<Integer> decode(String bitString) throws DecodingException {
8487 int val = FibonacciIntegerEncoder .decode (bitString .substring (startIndex , index + 2 )) + offset ;
8588 offset = val ;
8689 if (value .size () == MAX_SIZE ) {
87- throw new DecodingException ("FibonacciIntegerRange has too many values" );
90+ LOGGER .warning ("FibonacciIntegerRange has too many values" );
91+ break ;
8892 }
8993 value .add (val );
9094 startIndex = index + 2 ;
Original file line number Diff line number Diff line change 33import java .util .ArrayList ;
44import java .util .Collections ;
55import java .util .List ;
6+ import java .util .logging .Logger ;
67import java .util .regex .Pattern ;
78import com .iab .gpp .encoder .error .DecodingException ;
89
910public class FixedIntegerRangeEncoder {
1011
12+ private static final Logger LOGGER = Logger .getLogger (FixedIntegerRangeEncoder .class .getName ());
1113 // NOTE: This is a value roughly the 2x the size of this list
1214 // https://tools.iabtechlab.com/transparencycenter/explorer/business/gpp
1315 private static final int MAX_SIZE = 8192 ;
@@ -65,15 +67,17 @@ public static List<Integer> decode(String bitString) throws DecodingException {
6567 throw new DecodingException ("FixedIntegerRange has invalid range" );
6668 }
6769 if (value .size () + (end - start ) > MAX_SIZE ) {
68- throw new DecodingException ("FixedIntegerRange has too many values" );
70+ LOGGER .warning ("FixedIntegerRange has too many values" );
71+ break ;
6972 }
7073 for (int j = start ; j <= end ; j ++) {
7174 value .add (j );
7275 }
7376 } else {
7477 int val = FixedIntegerEncoder .decode (bitString .substring (startIndex , startIndex + 16 ));
7578 if (value .size () == MAX_SIZE ) {
76- throw new DecodingException ("FixedIntegerRange has too many values" );
79+ LOGGER .warning ("FixedIntegerRange has too many values" );
80+ break ;
7781 }
7882 value .add (val );
7983 startIndex += 16 ;
Original file line number Diff line number Diff line change 33import static org .junit .jupiter .api .Assertions .assertThrows ;
44import java .util .ArrayList ;
55import java .util .Arrays ;
6+ import java .util .List ;
67import org .junit .jupiter .api .Assertions ;
78import org .junit .jupiter .api .Test ;
89import com .iab .gpp .encoder .error .DecodingException ;
@@ -101,7 +102,6 @@ public void testDecode8() {
101102 @ Test
102103 public void testGiantRange () {
103104 String max = FibonacciIntegerEncoder .encode (FibonacciIntegerRangeEncoder .MAX_SIZE + 1 );
104- assertThrows (DecodingException .class , ()->
105- FibonacciIntegerRangeEncoder .decode ("000000000001111" + max ));
105+ Assertions .assertEquals (List .of (), FibonacciIntegerRangeEncoder .decode ("000000000001111" + max ));
106106 }
107107}
Original file line number Diff line number Diff line change 33import static org .junit .jupiter .api .Assertions .assertThrows ;
44import java .util .ArrayList ;
55import java .util .Arrays ;
6+ import java .util .List ;
67import org .junit .jupiter .api .Assertions ;
78import org .junit .jupiter .api .Test ;
89import com .iab .gpp .encoder .error .DecodingException ;
@@ -131,7 +132,6 @@ public void testDecode10() {
131132 @ Test
132133 public void testGiantRange () {
133134 String max = FibonacciIntegerEncoder .encode (FibonacciIntegerRangeEncoder .MAX_SIZE + 1 );
134- assertThrows (DecodingException .class , ()->
135- FixedIntegerRangeEncoder .decode ("00000000000110000000000000001" + max ));
135+ Assertions .assertEquals (List .of (), FixedIntegerRangeEncoder .decode ("00000000000110000000000000001" + max ));
136136 }
137137}
You can’t perform that action at this time.
0 commit comments