Skip to content

Commit 42f4d33

Browse files
committed
#10 fixed thread unsafe behavior of JBBPExpressionEvaluator, minor refactoring
1 parent 6fa530a commit 42f4d33

File tree

13 files changed

+354
-231
lines changed

13 files changed

+354
-231
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ For instance I have been very actively using the framework in [the ZX-Poly emula
1717

1818
Change log
1919
===========
20-
- **1.2.0**
20+
- **1.2.1-SNAPSHOT (Under development)**
21+
- __Fixed issue [#10 "assertArrayLength throws exception in multi-thread"](https://github.com/raydac/java-binary-block-parser/issues/10), many thanks to @sky4star for the bug report.__
22+
23+
- **1.2.0 (10-JUN-2015)**
2124
- Refactoring
2225
- Improved tree of JBBP exceptions
2326
- Fixed NPE in JBBPTextWriter for String field mapped to byte array
@@ -28,15 +31,17 @@ Change log
2831
- Improved inside script compiler and interpreter to support future extensions.
2932
- Fixed expression evaluator to support single char field names in expressions.
3033
- Added support of expressions in extra field numeric data part (example bit:(field*2))
31-
- **1.1.0**
34+
35+
- **1.1.0 (03-FEB-2015)**
3236
- Added support for mapped classes output into JBBPOut
3337
- Added JBBPTextWriter to log binary data as text with commentaries,tabs and separators
3438
- Fixed read byte counter, now it counts only fully processed bytes, if only several bits have been read from byte then the byte will not be counted until whole read
3539
- Fixed static fields including in mapping processes if class has marked by default Bin annotation
3640
- Added flag JBBPParser#FLAG_SKIP_REMAINING_FIELDS_IF_EOF to ignore remaining fields during parsing if EOF without exception
3741
- Added flag JBBPMapper#FLAG_IGNORE_MISSING_VALUES to ignore mapping for values which are not found in parsed source
3842
- Added new auxiliary methods in JBBPUtils
39-
- **1.0**
43+
44+
- **1.0 (08-AUG-2014)**
4045
- The Initial version
4146

4247
Maven dependency

src/main/java/com/igormaznitsa/jbbp/compiler/tokenizer/JBBPTokenizer.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ public final class JBBPTokenizer implements Iterable<JBBPToken>, Iterator<JBBPTo
5252
/**
5353
* Inside table to keep disabled names for fields.
5454
*/
55-
private static final Set<String> globalReservedTypeNames;
55+
private static final Set<String> GLOBAL_RESERVED_TYPE_NAMES;
5656

5757
static {
58-
globalReservedTypeNames = new HashSet<String>();
59-
globalReservedTypeNames.add("bit");
60-
globalReservedTypeNames.add("bool");
61-
globalReservedTypeNames.add("byte");
62-
globalReservedTypeNames.add("ubyte");
63-
globalReservedTypeNames.add("short");
64-
globalReservedTypeNames.add("ushort");
65-
globalReservedTypeNames.add("int");
66-
globalReservedTypeNames.add("long");
67-
globalReservedTypeNames.add("align");
68-
globalReservedTypeNames.add("skip");
69-
globalReservedTypeNames.add("$");
58+
GLOBAL_RESERVED_TYPE_NAMES = new HashSet<String>();
59+
GLOBAL_RESERVED_TYPE_NAMES.add("bit");
60+
GLOBAL_RESERVED_TYPE_NAMES.add("bool");
61+
GLOBAL_RESERVED_TYPE_NAMES.add("byte");
62+
GLOBAL_RESERVED_TYPE_NAMES.add("ubyte");
63+
GLOBAL_RESERVED_TYPE_NAMES.add("short");
64+
GLOBAL_RESERVED_TYPE_NAMES.add("ushort");
65+
GLOBAL_RESERVED_TYPE_NAMES.add("int");
66+
GLOBAL_RESERVED_TYPE_NAMES.add("long");
67+
GLOBAL_RESERVED_TYPE_NAMES.add("align");
68+
GLOBAL_RESERVED_TYPE_NAMES.add("skip");
69+
GLOBAL_RESERVED_TYPE_NAMES.add("$");
7070
}
7171

7272
private final Matcher matcher;
@@ -94,9 +94,9 @@ public JBBPTokenizer(final String str, final JBBPCustomFieldTypeProcessor custom
9494
JBBPUtils.assertNotNull(str, "String must not be null");
9595

9696
if (customFieldTypeProcessor == null){
97-
this.reservedTypeNames = globalReservedTypeNames;
97+
this.reservedTypeNames = GLOBAL_RESERVED_TYPE_NAMES;
9898
}else{
99-
this.reservedTypeNames = new HashSet<String>(globalReservedTypeNames);
99+
this.reservedTypeNames = new HashSet<String>(GLOBAL_RESERVED_TYPE_NAMES);
100100
for(final String customType : customFieldTypeProcessor.getCustomFieldTypes()){
101101
JBBPUtils.assertNotNull(customType, "Type must not be null");
102102
this.reservedTypeNames.add(customType);
@@ -246,7 +246,7 @@ else if ("<".equals(groupTypeByteOrder)) {
246246
* @return true if the name is global reserved one, false otherwise.
247247
*/
248248
public static boolean isGlobalReservedName(final String name) {
249-
return globalReservedTypeNames.contains(name);
249+
return GLOBAL_RESERVED_TYPE_NAMES.contains(name);
250250
}
251251

252252
/**

src/main/java/com/igormaznitsa/jbbp/compiler/varlen/JBBPEvaluatorFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
* @since 1.0
2626
*/
2727
public final class JBBPEvaluatorFactory {
28-
private static final JBBPEvaluatorFactory instance = new JBBPEvaluatorFactory();
28+
private static final JBBPEvaluatorFactory INSTANCE = new JBBPEvaluatorFactory();
2929

3030
private JBBPEvaluatorFactory(){
3131

3232
}
3333

3434
/**
3535
* Get an Instance of the factory.
36-
* @return the factory instance.
36+
* @return the factory INSTANCE.
3737
*/
3838
public static JBBPEvaluatorFactory getInstance(){
39-
return instance;
39+
return INSTANCE;
4040
}
4141

4242
/**

0 commit comments

Comments
 (0)