Skip to content

Commit

Permalink
Merge pull request FasterXML#39 from fge/master
Browse files Browse the repository at this point in the history
Fix two FindBugs items
  • Loading branch information
cowtowncoder committed Nov 13, 2012
2 parents d6d57e5 + 6ebc759 commit b47bc9f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public static class NopIndenter
{
private static final long serialVersionUID = 1L;

public static NopIndenter instance = new NopIndenter();
public static final NopIndenter instance = new NopIndenter();

public NopIndenter() { }
// @Override
Expand All @@ -332,7 +332,7 @@ public static class FixedSpaceIndenter
{
private static final long serialVersionUID = 1L;

public static FixedSpaceIndenter instance = new FixedSpaceIndenter();
public static final FixedSpaceIndenter instance = new FixedSpaceIndenter();

public FixedSpaceIndenter() { }

Expand All @@ -356,7 +356,7 @@ public static class Lf2SpacesIndenter
{
private static final long serialVersionUID = 1L;

public static Lf2SpacesIndenter instance = new Lf2SpacesIndenter();
public static final Lf2SpacesIndenter instance = new Lf2SpacesIndenter();

final static String SYSTEM_LINE_SEPARATOR;
static {
Expand Down
73 changes: 47 additions & 26 deletions src/main/java/com/fasterxml/jackson/core/util/VersionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,58 @@ protected VersionUtil()
*/
public static Version versionFor(Class<?> cls)
{
InputStream in;
Version version = null;
final InputStream in = cls.getResourceAsStream(VERSION_FILE);

if (in == null)
return Version.unknownVersion();

try {
in = cls.getResourceAsStream(VERSION_FILE);
if (in != null) {
InputStreamReader reader = new InputStreamReader(in, "UTF-8");
try {
return doReadVersion(reader);
} finally {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
String groupStr = null, artifactStr = null;
String versionStr = br.readLine();
if (versionStr != null) {
groupStr = br.readLine();
if (groupStr != null) {
groupStr = groupStr.trim();
artifactStr = br.readLine();
if (artifactStr != null) {
artifactStr = artifactStr.trim();
}
}
}
version = parseVersion(versionStr, groupStr, artifactStr);
} finally {
try {
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
reader.close();
} catch (IOException ignored) {
}
}
} catch (IOException e) { }
return (version == null) ? Version.unknownVersion() : version;
} catch (UnsupportedEncodingException e) {
return Version.unknownVersion();
} finally {
try {
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

private static Version doReadVersion(final Reader reader)
{
String version = null, group = null, artifact = null;

final BufferedReader br = new BufferedReader(reader);
try {
version = br.readLine();
if (version != null) {
group = br.readLine();
if (group != null)
artifact = br.readLine();
}
} catch (IOException ignored) {
} finally {
try {
br.close();
} catch (IOException ignored) {
}
}

// We don't trim() version: parseVersion() takes care ot that
if (group != null)
group = group.trim();
if (artifact != null)
artifact = artifact.trim();
return parseVersion(version, group, artifact);
}

/**
Expand Down

0 comments on commit b47bc9f

Please sign in to comment.