Skip to content

Commit 95b7620

Browse files
committed
Some more lgtm.com fixes/work-arounds
1 parent 78d096a commit 95b7620

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ protected final void _loadToHaveAtLeast(int minAvailable) throws IOException
10991099
// No input stream, no leading (either we are closed, or have non-stream input source)
11001100
if (_inputStream == null) {
11011101
_reportError("Needed to read %d bytes, reached end-of-input", minAvailable);
1102+
return; // never gets here, but sec tools complain without
11021103
}
11031104
while (_inputEnd < minAvailable) {
11041105
int count = _inputStream.read(_inputBuffer, _inputEnd, _inputBuffer.length - _inputEnd);

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,13 @@ public static Schema simpleSchema(JsonFormatTypes type, JavaType hint)
151151
return Schema.create(Schema.Type.NULL);
152152
case NUMBER:
153153
// 16-Feb-2017, tatu: Fixed as suggested by `baharclerode@github`
154-
if (hint.hasRawClass(float.class)) {
155-
return Schema.create(Schema.Type.FLOAT);
156-
}
157-
if (hint.hasRawClass(long.class)) {
158-
return Schema.create(Schema.Type.LONG);
154+
if (hint != null) {
155+
if (hint.hasRawClass(float.class)) {
156+
return Schema.create(Schema.Type.FLOAT);
157+
}
158+
if (hint.hasRawClass(long.class)) {
159+
return Schema.create(Schema.Type.LONG);
160+
}
159161
}
160162
return Schema.create(Schema.Type.DOUBLE);
161163
case STRING:

protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java

+2
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public final void writeStartArray() throws IOException
394394
}
395395
if (_currField == null) { // just a sanity check
396396
_reportError("Can not write START_ARRAY without field (message type "+_currMessage.getName()+")");
397+
return; // never gets here but code analyzers can't see that
397398
}
398399
if (!_currField.isArray()) {
399400
_reportError("Can not write START_ARRAY: field '"+_currField.name+"' not declared as 'repeated'");
@@ -568,6 +569,7 @@ private void _verifyArrayWrite(Object array) throws IOException
568569
}
569570
if (_currField == null) { // inlined _verifyValueWrite
570571
_reportError("Can not write START_ARRAY without field (message type "+_currMessage.getName()+")");
572+
return; // never gets here but need to help code analyzers
571573
}
572574
if (!_currField.isArray()) {
573575
_reportError("Can not write START_ARRAY: field '"+_currField.name+"' not declared as 'repeated'");

protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufParser.java

+1
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ public JsonToken nextToken() throws IOException
545545
case STATE_INITIAL:
546546
if (_schema == null) {
547547
_reportError("No Schema has been assigned: can not decode content");
548+
return null; // never gets here but needed for code analyzers benefit
548549
}
549550
_currentMessage = _schema.getRootType();
550551
_currentField = _currentMessage.firstField();

0 commit comments

Comments
 (0)