Skip to content

Commit

Permalink
improve code style
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlietz committed Nov 25, 2024
1 parent 46466ec commit 7ef7d03
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public InternalKarafDistributionConfigurationOption(
@Override
public String getKarafVersion() {
String internalVersion = super.getKarafVersion();
if (internalVersion != null && internalVersion.length() != 0) {
if (internalVersion != null && !internalVersion.isEmpty()) {
return internalVersion;
}
if (!distributionInfo.exists()) {
throw new IllegalStateException(
"Either distribution.info or the property itself has to define a karaf version.");
}
String retrieveProperty = retrieveProperty(KARAF_VERSION);
if (retrieveProperty == null || retrieveProperty.length() == 0) {
if (retrieveProperty == null || retrieveProperty.isEmpty()) {
throw new IllegalStateException(
"Either distribution.info or the property itself has to define a karaf version.");
}
Expand All @@ -61,32 +61,26 @@ public String getKarafVersion() {
@Override
public String getName() {
String internalName = super.getName();
if (internalName != null && internalName.length() != 0) {
if (internalName != null && !internalName.isEmpty()) {
return internalName;
}
if (!distributionInfo.exists()) {
throw new IllegalStateException(
"Either distribution.info or the property itself has to define a name for the distribution..");
}
String retrieveProperty = retrieveProperty(NAME);
if (retrieveProperty == null || retrieveProperty.length() == 0) {
if (retrieveProperty == null || retrieveProperty.isEmpty()) {
throw new IllegalStateException(
"Either distribution.info or the property itself has to define a name for the distribution..");
}
return retrieveProperty;
}

private String retrieveProperty(String key) {
try {
FileInputStream fileInputStream = new FileInputStream(distributionInfo);
try {
Properties props = new Properties();
props.load(fileInputStream);
return props.getProperty(key);
}
finally {
fileInputStream.close();
}
try (FileInputStream fileInputStream = new FileInputStream(distributionInfo)) {
Properties props = new Properties();
props.load(fileInputStream);
return props.getProperty(key);
}
// CHECKSTYLE:SKIP
catch (Exception e) {
Expand Down

0 comments on commit 7ef7d03

Please sign in to comment.