Skip to content

Commit 3d8bafd

Browse files
committed
Resolve last lgtm warnings
1 parent 778def9 commit 3d8bafd

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

src/main/java/com/fasterxml/aalto/in/ByteSourceBootstrapper.java

+17-21
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public final class ByteSourceBootstrapper
4848
/**
4949
* Underlying InputStream to use for reading content.
5050
*/
51-
final InputStream _in;
51+
protected final InputStream _in;
5252

5353
/*
5454
/**********************************************************************
5555
/* Input buffering
5656
/**********************************************************************
5757
*/
5858

59-
final byte[] _inputBuffer;
59+
protected final byte[] _inputBuffer;
6060

6161
private int _inputPtr;
6262

@@ -68,11 +68,11 @@ public final class ByteSourceBootstrapper
6868
/**********************************************************************
6969
*/
7070

71-
boolean mBigEndian = true;
72-
int mBytesPerChar = 0; // 0 means "dunno yet"
71+
protected boolean mBigEndian = true;
72+
protected int mBytesPerChar = 0; // 0 means "dunno yet"
7373

74-
boolean mHadBOM = false;
75-
boolean mByteSizeFound = false;
74+
protected boolean mHadBOM = false;
75+
protected boolean mByteSizeFound = false;
7676

7777
/*
7878
/**********************************************************************
@@ -164,9 +164,9 @@ public XmlScanner doBootstrap() throws IOException, XMLStreamException
164164
return new Utf8Scanner(_config,
165165
_in, _inputBuffer, _inputPtr, _inputLen);
166166
} else if (normEnc.startsWith(CharsetNames.CS_UTF32)) {
167-
/* Since this is such a rare encoding, we'll just create
168-
* a Reader, and dispatch it to reader scanner?
169-
*/
167+
// Since this is such a rare encoding, we'll just create
168+
// a Reader, and dispatch it to reader scanner?
169+
170170
// let's augment with actual endianness info
171171
if (normEnc == CharsetNames.CS_UTF32) {
172172
normEnc = mBigEndian ? CharsetNames.CS_UTF32BE : CharsetNames.CS_UTF32LE;
@@ -176,19 +176,17 @@ public XmlScanner doBootstrap() throws IOException, XMLStreamException
176176
return new ReaderScanner(_config, r);
177177
}
178178

179-
/* And finally, if all else fails, we'll also fall back to
180-
* using JDK-provided decoders and ReaderScanner:
181-
*/
179+
// And finally, if all else fails, we'll also fall back to
180+
// using JDK-provided decoders and ReaderScanner:
182181
InputStream in = _in;
183182
if (_inputPtr < _inputLen) {
184-
in = new MergedStream(_config, in, _inputBuffer, _inputPtr, _inputLen);
183+
in = new MergedStream(_config, in, _inputBuffer, _inputPtr, _inputLen); // lgtm [java/input-resource-leak]
185184
}
186185
if (normEnc == CharsetNames.CS_UTF16) {
187186
normEnc = mBigEndian ? CharsetNames.CS_UTF16BE : CharsetNames.CS_UTF16LE;
188187
}
189188
try {
190-
Reader r = new InputStreamReader(in, normEnc);
191-
return new ReaderScanner(_config, r);
189+
return new ReaderScanner(_config, new InputStreamReader(in, normEnc));
192190
} catch (UnsupportedEncodingException usex) {
193191
throw new IoStreamException("Unsupported encoding: "+usex.getMessage());
194192
}
@@ -221,9 +219,8 @@ private void determineStreamEncoding()
221219
| ((_inputBuffer[_inputPtr+2] & 0xFF) << 8)
222220
| (_inputBuffer[_inputPtr+3] & 0xFF);
223221

224-
/* Handling of (usually) optional BOM (required for
225-
* multi-byte formats); first 32-bit charsets:
226-
*/
222+
// Handling of (usually) optional BOM (required for
223+
// multi-byte formats); first 32-bit charsets:
227224
switch (quartet) {
228225
case 0x0000FEFF:
229226
mBigEndian = true;
@@ -760,9 +757,8 @@ private void verifyEncoding(String id, int bpc)
760757
throws XMLStreamException
761758
{
762759
if (mByteSizeFound) {
763-
/* Let's verify that if we matched an encoding, it's the same
764-
* as what was declared...
765-
*/
760+
// Let's verify that if we matched an encoding, it's the same
761+
// as what was declared...
766762
if (bpc != mBytesPerChar) {
767763
reportXmlProblem("Declared encoding '"+id+"' uses "+bpc
768764
+" bytes per character; but physical encoding appeared to use "+mBytesPerChar+"; cannot decode");

src/main/java/com/fasterxml/aalto/in/FixedNsContext.java

+15-17
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public final class FixedNsContext
2323
}
2424

2525
/*
26-
////////////////////////////////////////////////////////
27-
// Persisted namespace information
28-
////////////////////////////////////////////////////////
26+
/**********************************************************************
27+
/* Persisted namespace information
28+
/**********************************************************************
2929
*/
3030

3131
/**
@@ -89,17 +89,16 @@ public FixedNsContext reuseOrCreate(final NsDeclaration currLastDecl)
8989
}
9090

9191
/*
92-
/////////////////////////////////////////////
93-
// NamespaceContext API
94-
/////////////////////////////////////////////
92+
/**********************************************************************
93+
/* NamespaceContext API
94+
/**********************************************************************
9595
*/
9696

9797
@Override
9898
public final String getNamespaceURI(String prefix)
9999
{
100-
/* First the known offenders; invalid args, 2 predefined xml
101-
* namespace prefixes
102-
*/
100+
// First the known offenders; invalid args, 2 predefined xml
101+
// namespace prefixes
103102
if (prefix == null) {
104103
throw new IllegalArgumentException("Null prefix not allowed");
105104
}
@@ -115,7 +114,7 @@ public final String getNamespaceURI(String prefix)
115114
String[] ns = _declarationData;
116115
for (int i = 0, len = ns.length; i < len; i += 2) {
117116
if (prefix.equals(ns[i])) {
118-
return ns[i+1];
117+
return ns[i+1]; // lgtm [java/index-out-of-bounds]
119118
}
120119
}
121120
return null;
@@ -124,9 +123,8 @@ public final String getNamespaceURI(String prefix)
124123
@Override
125124
public final String getPrefix(String nsURI)
126125
{
127-
/* First the known offenders; invalid args, 2 predefined xml
128-
* namespace prefixes
129-
*/
126+
// First the known offenders; invalid args, 2 predefined xml
127+
// namespace prefixes
130128
if (nsURI == null || nsURI.length() == 0) {
131129
throw new IllegalArgumentException("Illegal to pass null/empty prefix as argument.");
132130
}
@@ -209,9 +207,9 @@ public final Iterator<String> getPrefixes(String nsURI)
209207
}
210208

211209
/*
212-
/////////////////////////////////////////////
213-
// Other methods
214-
/////////////////////////////////////////////
210+
/**********************************************************************
211+
/* Standard method overrides
212+
/**********************************************************************
215213
*/
216214

217215
@Override
@@ -227,7 +225,7 @@ public String toString()
227225
sb.append(", ");
228226
}
229227
sb.append('"').append(_declarationData[i]).append("\"->\"");
230-
sb.append(_declarationData[i+1]).append('"');
228+
sb.append(_declarationData[i+1]).append('"'); // lgtm [java/index-out-of-bounds]
231229
}
232230
sb.append(']');
233231
return sb.toString();

0 commit comments

Comments
 (0)