Skip to content

Commit 44099f4

Browse files
committed
Fix warnings.
1 parent d3641a3 commit 44099f4

5 files changed

Lines changed: 14 additions & 21 deletions

File tree

atplug-plugin-gradle/src/main/java/com/diffplug/atplug/tooling/gradle/PlugGenerateTask.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.io.BufferedInputStream;
2323
import java.io.BufferedOutputStream;
2424
import java.io.File;
25-
import java.io.FileInputStream;
26-
import java.io.FileOutputStream;
2725
import java.io.IOException;
2826
import java.io.InputStream;
2927
import java.io.OutputStream;
@@ -161,8 +159,7 @@ private File manifestFile() {
161159
private Manifest loadManifest() {
162160
Manifest manifest = new Manifest();
163161
if (manifestFile().isFile()) {
164-
try (InputStream raw = new FileInputStream(manifestFile());
165-
InputStream input = new BufferedInputStream(raw)) {
162+
try (InputStream input = new BufferedInputStream(Files.newInputStream(manifestFile().toPath()))) {
166163
manifest.read(input);
167164
} catch (IOException e) {
168165
throw new RuntimeException(e);
@@ -171,17 +168,16 @@ private Manifest loadManifest() {
171168
return manifest;
172169
}
173170

174-
private void saveManifest(Manifest manifest) throws IOException {
171+
private void saveManifest(Manifest manifest) {
175172
FileMisc.mkdirs(manifestFile().getParentFile());
176-
try (OutputStream raw = new FileOutputStream(manifestFile());
177-
OutputStream output = new BufferedOutputStream(raw)) {
173+
try (OutputStream output = new BufferedOutputStream(Files.newOutputStream(manifestFile().toPath()))) {
178174
manifest.write(output);
179175
} catch (IOException e) {
180176
throw new RuntimeException(e);
181177
}
182178
}
183179

184-
private SortedMap<String, String> generate() throws Throwable {
180+
private SortedMap<String, String> generate() {
185181
PlugGeneratorJavaExecable input = new PlugGeneratorJavaExecable(new ArrayList<>(getClassesFolders().getFiles()), getJarsToLinkAgainst().getFiles());
186182
if (getLauncher().isPresent()) {
187183
WorkQueue workQueue = getWorkerExecutor().processIsolation(workerSpec -> {

atplug-runtime/src/main/java/com/diffplug/atplug/Metadata.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
*/
77
package com.diffplug.atplug
88

9-
import java.lang.annotation.Documented
10-
119
/** Marks that a method is used to generate metadata, and should therefore return a constant. */
12-
@Documented
13-
@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
10+
@Retention(AnnotationRetention.SOURCE)
1411
@Target(
1512
AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
1613
annotation class Metadata

atplug-runtime/src/main/java/com/diffplug/atplug/Plug.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package com.diffplug.atplug
99
import kotlin.reflect.KClass
1010

1111
/** Annotation which signals that this class implements the given socket. */
12-
@kotlin.annotation.Retention(AnnotationRetention.BINARY)
12+
@Retention(AnnotationRetention.BINARY)
1313
@Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS)
1414
annotation class Plug(
1515
/** Socket type which this plug implements. */

atplug-runtime/src/main/java/com/diffplug/atplug/PlugInstanceMap.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PlugInstanceMap {
1111
internal val instanceMap = mutableMapOf<PlugDescriptor, Any>()
1212

1313
fun putDescriptor(clazz: String, descriptor: PlugDescriptor) {
14-
val descriptors = descriptorMap.computeIfAbsent(clazz) { mutableListOf<PlugDescriptor>() }
14+
val descriptors = descriptorMap.computeIfAbsent(clazz) { mutableListOf() }
1515
descriptors.add(descriptor)
1616
}
1717

atplug-runtime/src/main/java/com/diffplug/atplug/PlugRegistry.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface PlugRegistry {
4848
if (registry is Eager) {
4949
registry.setHarness(data)
5050
} else {
51-
throw AssertionError("Registry must not be set, was ${registry}")
51+
throw AssertionError("Registry must not be set, was $registry")
5252
}
5353
}
5454
}
@@ -77,7 +77,7 @@ interface PlugRegistry {
7777
val component = parseComponent(asString, servicePath)
7878
synchronized(this) {
7979
data.putDescriptor(component.provides, component)
80-
owners.get(component.provides)?.doRegister(component)
80+
owners[component.provides]?.doRegister(component)
8181
}
8282
}
8383
} catch (e: ZipException) {
@@ -103,8 +103,8 @@ interface PlugRegistry {
103103
override fun <T> registerSocket(socketClass: Class<T>, socketOwner: SocketOwner<T>) {
104104
synchronized(this) {
105105
val prevOwner = owners.put(socketClass.name, socketOwner)
106-
assert(prevOwner == null) { "Multiple owners registered for ${socketClass}" }
107-
data.descriptorMap.get(socketClass.name)?.forEach(socketOwner::doRegister)
106+
assert(prevOwner == null) { "Multiple owners registered for $socketClass" }
107+
data.descriptorMap[socketClass.name]?.forEach(socketOwner::doRegister)
108108
}
109109
}
110110

@@ -128,7 +128,7 @@ interface PlugRegistry {
128128
"Class must have a no-arg constructor, but it didn't. " +
129129
clazz +
130130
" " +
131-
Arrays.asList(*clazz.constructors)
131+
listOf(*clazz.constructors)
132132
}
133133
return constructor.newInstance() as T
134134
}
@@ -138,12 +138,12 @@ interface PlugRegistry {
138138
fun setHarness(newHarness: PlugInstanceMap?) {
139139
val toRemove = lastHarness ?: data
140140
toRemove.descriptorMap.forEach { (clazz, plugDescriptors) ->
141-
owners.get(clazz)?.let { owner -> plugDescriptors.forEach(owner::doRemove) }
141+
owners[clazz]?.let { owner -> plugDescriptors.forEach(owner::doRemove) }
142142
}
143143

144144
val toAdd = newHarness ?: data
145145
toAdd.descriptorMap.forEach { (clazz, plugDescriptors) ->
146-
owners.get(clazz)?.let { owner -> plugDescriptors.forEach(owner::doRegister) }
146+
owners[clazz]?.let { owner -> plugDescriptors.forEach(owner::doRegister) }
147147
}
148148
lastHarness = newHarness
149149
}

0 commit comments

Comments
 (0)