Skip to content

Commit

Permalink
✔Use returnClass to avoid nulls, reset on EOF.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjritola committed Apr 17, 2024
1 parent 52b1cfb commit 3084b35
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/jtrfp/jfdt/Parser.java
Expand Up @@ -239,7 +239,7 @@ private <CLASS> CLASS get(ThirdPartyParseable obj, String property, Class <? ext
Method method = obj.getClass().getMethod(prefix+Character.toUpperCase(property.charAt(0))+property.substring(1), nullClasses);
if(propertyReturnClass==String.class){
Object result = method.invoke(obj, (Object[])null);
if(!result.getClass().isEnum())return (CLASS)new String(""+result);
if(!propertyReturnClass.isEnum())return (CLASS)new String(""+result);
else return (CLASS)(((Enum<?>)result).ordinal()+"");
}
return (CLASS)method.invoke(obj, (Object[])null);
Expand Down Expand Up @@ -558,9 +558,11 @@ public void read(EndianAwareDataInputStream is,
is.mark(b.length);
try{is.readFully(b);}
catch(EOFException e){
is.reset();
throw new EOFException("Occurred at byte "+readTally+" (0x"+Long.toHexString(readTally).toUpperCase()+")");
// FLIP_ENDIAN isn't going to help here so it won't be considered.
}catch(Exception e) {
is.reset();
if(failureBehavior == FailureBehavior.UNRECOGNIZED_FORMAT)
throw new UnrecognizedFormatException("Occurred at byte "+readTally+" (0x"+Long.toHexString(readTally).toUpperCase()+")",e);
else
Expand Down

0 comments on commit 3084b35

Please sign in to comment.