Skip to content

Commit 8f612f5

Browse files
committed
LintRuleDescriptor: stop using GUtil
1 parent 10d25f4 commit 8f612f5

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

src/main/groovy/com/netflix/nebula/lint/plugin/LintRuleDescriptor.groovy

+38-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,52 @@
1717
package com.netflix.nebula.lint.plugin
1818

1919
import groovy.transform.Canonical
20-
import org.gradle.util.GUtil
20+
import org.gradle.api.UncheckedIOException
21+
22+
import javax.annotation.Nullable
2123

2224
@Canonical
2325
class LintRuleDescriptor {
2426
URL propertiesFileUrl
2527

2628
String getImplementationClassName() {
27-
GUtil.loadProperties(propertiesFileUrl).getProperty('implementation-class')
29+
loadProperties(propertiesFileUrl).getProperty('implementation-class')
2830
}
2931

3032
List<String> getIncludes() {
31-
GUtil.loadProperties(propertiesFileUrl).getProperty('includes')?.split(',') ?: [] as List<String>
33+
loadProperties(propertiesFileUrl).getProperty('includes')?.split(',') ?: [] as List<String>
34+
}
35+
36+
private static Properties loadProperties(URL url) {
37+
try {
38+
URLConnection uc = url.openConnection()
39+
uc.setUseCaches(false)
40+
return loadProperties(uc.inputStream)
41+
} catch (IOException e) {
42+
throw new UncheckedIOException(e)
43+
}
44+
}
45+
46+
private static Properties loadProperties(InputStream inputStream) {
47+
Properties properties = new Properties()
48+
try {
49+
properties.load(inputStream)
50+
} catch (IOException e) {
51+
throw new UncheckedIOException(e)
52+
} finally {
53+
closeQuietly(inputStream)
54+
}
55+
56+
return properties
57+
}
58+
59+
private static void closeQuietly(@Nullable Closeable resource) {
60+
try {
61+
if (resource != null) {
62+
resource.close()
63+
}
64+
} catch (IOException e) {
65+
}
66+
3267
}
3368
}

0 commit comments

Comments
 (0)