mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-10 09:20:28 +00:00
Fix a couple of warnings
This commit is contained in:
parent
3b8813cf8f
commit
eead67e314
@ -116,6 +116,7 @@ public final class MethodResult {
|
|||||||
* @return The method result which represents this yield.
|
* @return The method result which represents this yield.
|
||||||
* @see #pullEvent(String, ILuaCallback)
|
* @see #pullEvent(String, ILuaCallback)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("NamedLikeContextualKeyword")
|
||||||
public static MethodResult yield(@Nullable Object[] arguments, ILuaCallback callback) {
|
public static MethodResult yield(@Nullable Object[] arguments, ILuaCallback callback) {
|
||||||
Objects.requireNonNull(callback, "callback cannot be null");
|
Objects.requireNonNull(callback, "callback cannot be null");
|
||||||
return new MethodResult(arguments, callback);
|
return new MethodResult(arguments, callback);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package dan200.computercraft.core.apis.http.options;
|
package dan200.computercraft.core.apis.http.options;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for a given HTTP request or websocket, which control its resource constraints.
|
* Options for a given HTTP request or websocket, which control its resource constraints.
|
||||||
@ -14,5 +15,6 @@ package dan200.computercraft.core.apis.http.options;
|
|||||||
* @param websocketMessage The maximum size of a websocket message (outgoing and incoming).
|
* @param websocketMessage The maximum size of a websocket message (outgoing and incoming).
|
||||||
* @param useProxy Whether to use the configured proxy.
|
* @param useProxy Whether to use the configured proxy.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public record Options(Action action, long maxUpload, long maxDownload, int websocketMessage, boolean useProxy) {
|
public record Options(Action action, long maxUpload, long maxDownload, int websocketMessage, boolean useProxy) {
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package dan200.computercraft.core.apis.http.options;
|
package dan200.computercraft.core.apis.http.options;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.Immutable;
|
||||||
import com.google.errorprone.annotations.concurrent.LazyInit;
|
import com.google.errorprone.annotations.concurrent.LazyInit;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -11,6 +12,7 @@ import java.util.Optional;
|
|||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.OptionalLong;
|
import java.util.OptionalLong;
|
||||||
|
|
||||||
|
@Immutable
|
||||||
public final class PartialOptions {
|
public final class PartialOptions {
|
||||||
public static final PartialOptions DEFAULT = new PartialOptions(
|
public static final PartialOptions DEFAULT = new PartialOptions(
|
||||||
null, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty(), Optional.empty()
|
null, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty(), Optional.empty()
|
||||||
|
@ -27,7 +27,7 @@ final class ResultHelpers {
|
|||||||
return throwUnchecked0(t);
|
return throwUnchecked0(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "TypeParameterUnusedInFormals" })
|
||||||
private static <T extends Throwable> T throwUnchecked0(Throwable t) throws T {
|
private static <T extends Throwable> T throwUnchecked0(Throwable t) throws T {
|
||||||
throw (T) t;
|
throw (T) t;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,17 @@ class LuaCoverage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void write(Writer out) throws IOException {
|
void write(Writer out) throws IOException {
|
||||||
Files.find(ROOT, Integer.MAX_VALUE, (path, attr) -> attr.isRegularFile()).forEach(path -> {
|
try (var files = Files.find(ROOT, Integer.MAX_VALUE, (path, attr) -> attr.isRegularFile())) {
|
||||||
|
files.forEach(path -> writeSingleFile(out, path));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var filename : coverage.keySet()) {
|
||||||
|
if (filename.startsWith("/test-rom/")) continue;
|
||||||
|
LOG.warn("Unknown file {}", filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeSingleFile(Writer out, Path path) {
|
||||||
var relative = ROOT.relativize(path);
|
var relative = ROOT.relativize(path);
|
||||||
var full = relative.toString().replace('\\', '/');
|
var full = relative.toString().replace('\\', '/');
|
||||||
if (!full.endsWith(".lua")) return;
|
if (!full.endsWith(".lua")) return;
|
||||||
@ -63,12 +73,6 @@ class LuaCoverage {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
for (var filename : coverage.keySet()) {
|
|
||||||
if (filename.startsWith("/test-rom/")) continue;
|
|
||||||
LOG.warn("Unknown file {}", filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCoverageFor(Writer out, Path fullName, Map<Integer, Integer> visitedLines) throws IOException {
|
private void writeCoverageFor(Writer out, Path fullName, Map<Integer, Integer> visitedLines) throws IOException {
|
||||||
|
@ -101,7 +101,7 @@ public class ComputerBootstrap {
|
|||||||
try {
|
try {
|
||||||
context.ensureClosed(1, TimeUnit.SECONDS);
|
context.ensureClosed(1, TimeUnit.SECONDS);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new IllegalStateException("Runtime thread was interrupted", e);
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class ComputerThreadRunner implements AutoCloseable {
|
|||||||
} finally {
|
} finally {
|
||||||
errorLock.unlock();
|
errorLock.unlock();
|
||||||
}
|
}
|
||||||
} while (worker.executed == 0 || thread.hasPendingWork());
|
} while (!worker.executed || thread.hasPendingWork());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("errorLock")
|
@GuardedBy("errorLock")
|
||||||
@ -87,7 +87,7 @@ public class ComputerThreadRunner implements AutoCloseable {
|
|||||||
private final Task run;
|
private final Task run;
|
||||||
private final ComputerScheduler.Executor executor;
|
private final ComputerScheduler.Executor executor;
|
||||||
private long[] totals = new long[16];
|
private long[] totals = new long[16];
|
||||||
volatile int executed = 0;
|
private volatile boolean executed = false;
|
||||||
|
|
||||||
private Worker(ComputerScheduler scheduler, Task run) {
|
private Worker(ComputerScheduler scheduler, Task run) {
|
||||||
this.run = run;
|
this.run = run;
|
||||||
@ -102,7 +102,7 @@ public class ComputerThreadRunner implements AutoCloseable {
|
|||||||
public void work() {
|
public void work() {
|
||||||
try {
|
try {
|
||||||
run.run(executor);
|
run.run(executor);
|
||||||
executed++;
|
executed = true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
errorLock.lock();
|
errorLock.lock();
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user