Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Taz03 committed May 22, 2024
1 parent 60be624 commit e31f71f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public class DockerService implements DisposableBean {
private final DockerClient client;

public DockerService(Config config) {
DefaultDockerClientConfig clientConfig
= DefaultDockerClientConfig.createDefaultConfigBuilder().build();
ApacheDockerHttpClient httpClient
= new ApacheDockerHttpClient.Builder()
DefaultDockerClientConfig clientConfig =
DefaultDockerClientConfig.createDefaultConfigBuilder().build();
ApacheDockerHttpClient httpClient =
new ApacheDockerHttpClient.Builder()
.dockerHost(clientConfig.getDockerHost())
.sslConfig(clientConfig.getSSLConfig())
.responseTimeout(Duration.ofSeconds(config.dockerResponseTimeout()))
Expand All @@ -46,8 +46,8 @@ public DockerService(Config config) {
private void cleanupLeftovers(UUID currentId) {
for (Container container : client.listContainersCmd().withLabelFilter(Set.of(WORKER_LABEL))
.exec()) {
String containerHumanName
= container.getId() + " " + Arrays.toString(container.getNames());
String containerHumanName =
container.getId() + " " + Arrays.toString(container.getNames());
LOGGER.info("Found worker container '{}'", containerHumanName);
if (!container.getLabels().get(WORKER_LABEL).equals(currentId.toString())) {
LOGGER.info("Killing container '{}'", containerHumanName);
Expand All @@ -65,8 +65,8 @@ public String spawnContainer(
long sysoutLimit
) throws InterruptedException {
String imageName = "togetherjava.org:5001/togetherjava/jshellwrapper";
boolean presentLocally
= client.listImagesCmd().withFilter("reference", List.of(imageName)).exec().stream()
boolean presentLocally =
client.listImagesCmd().withFilter("reference", List.of(imageName)).exec().stream()
.flatMap(it -> Arrays.stream(it.getRepoTags()))
.anyMatch(it -> it.endsWith(":master"));

Expand Down Expand Up @@ -122,8 +122,8 @@ public InputStream startAndAttachToContainer(
@Override
public void onNext(Frame object) {
try {
String payloadString
= new String(object.getPayload(), StandardCharsets.UTF_8);
String payloadString =
new String(object.getPayload(), StandardCharsets.UTF_8);
if (object.getStreamType() == StreamType.STDOUT) {
pipeOut.write(object.getPayload());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public JShellService(
throw new DockerException("The session isn't completely destroyed, try again later.");
}
try {
String containerId
= dockerService.spawnContainer(
String containerId =
dockerService.spawnContainer(
maxMemory,
(long) Math.ceil(cpus),
cpuSetCpus,
Expand All @@ -68,12 +68,12 @@ public JShellService(
sysOutCharLimit
);
PipedInputStream containerInput = new PipedInputStream();
this.writer
= new BufferedWriter(
this.writer =
new BufferedWriter(
new OutputStreamWriter(new PipedOutputStream(containerInput))
);
InputStream containerOutput
= dockerService.startAndAttachToContainer(containerId, containerInput);
InputStream containerOutput =
dockerService.startAndAttachToContainer(containerId, containerInput);
reader = new BufferedReader(new InputStreamReader(containerOutput));
writer.write(sanitize(startupScript));
writer.newLine();
Expand Down Expand Up @@ -125,14 +125,14 @@ private JShellResult readResult() throws IOException, NumberFormatException, Doc
final int snippetsCount = Integer.parseInt(reader.readLine());
List<JShellSnippetResult> snippetResults = new ArrayList<>();
for (int i = 0; i < snippetsCount; i++) {
SnippetStatus status
= Utils.nameOrElseThrow(
SnippetStatus status =
Utils.nameOrElseThrow(
SnippetStatus.class,
reader.readLine(),
name -> new DockerException(name + " isn't an enum constant")
);
SnippetType type
= Utils.nameOrElseThrow(
SnippetType type =
Utils.nameOrElseThrow(
SnippetType.class,
reader.readLine(),
name -> new DockerException(name + " isn't an enum constant")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ private void initScheduler() {
jshellSessions.keySet().stream()
.filter(id -> jshellSessions.get(id).isClosed())
.forEach(this::notifyDeath);
List<String> toDie
= jshellSessions.keySet().stream()
List<String> toDie =
jshellSessions.keySet().stream()
.filter(id -> jshellSessions.get(id).shouldDie())
.toList();
for (String id : toDie) {
Expand Down Expand Up @@ -123,8 +123,8 @@ private synchronized JShellService createSession(
);
}
LOGGER.info("Creating session : {}.", sessionInfo);
JShellService service
= new JShellService(
JShellService service =
new JShellService(
dockerService,
this,
sessionInfo.id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ private StartupScriptsService() {
scripts = new EnumMap<>(StartupScriptId.class);
for (StartupScriptId id : StartupScriptId.values()) {
try (
InputStream scriptStream
= Objects.requireNonNull(
InputStream scriptStream =
Objects.requireNonNull(
StartupScriptsService.class.getResourceAsStream(
"/jshell_startup/" + id + ".jsh"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ private EvalResult eval(JShell shell, String code, AtomicBoolean hasStopped) {
while (!code.isEmpty()) {
var completion = shell.sourceCodeAnalysis().analyzeCompletion(clean(code));
if (!completion.completeness().isComplete()) {
abortion
= new JShellEvalAbortion(
abortion =
new JShellEvalAbortion(
code,
"",
new JShellEvalAbortionCause.SyntaxErrorAbortionCause()
Expand All @@ -96,17 +96,17 @@ private EvalResult eval(JShell shell, String code, AtomicBoolean hasStopped) {
List<SnippetEvent> evalEvents = shell.eval(completion.source());
JShellEvalAbortionCause abortionCause = handleEvents(shell, evalEvents, resultEvents);
if (abortionCause != null) {
abortion
= new JShellEvalAbortion(
abortion =
new JShellEvalAbortion(
completion.source(),
completion.remaining(),
abortionCause
);
break;
}
if (hasStopped.get()) {
abortion
= new JShellEvalAbortion(
abortion =
new JShellEvalAbortion(
completion.source(),
completion.remaining(),
new JShellEvalAbortionCause.TimeoutAbortionCause()
Expand Down Expand Up @@ -190,14 +190,14 @@ private void eval(
StringOutputStream jshellOut
) {
AtomicBoolean hasStopped = new AtomicBoolean();
TimeoutWatcher watcher
= new TimeoutWatcher(
TimeoutWatcher watcher =
new TimeoutWatcher(
config.evalTimeoutSeconds(),
new JShellEvalStop(shell, hasStopped)
);
int lineCount = Integer.parseInt(processIn.nextLine());
String code
= IntStream.range(0, lineCount)
String code =
IntStream.range(0, lineCount)
.mapToObj(i -> processIn.nextLine())
.collect(Collectors.joining("\n"));
ok(processOut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void write(byte[] b, int off, int len) {
public Result readAll() {
if (index > bytes.length)
throw new IllegalStateException(); // Should never happen
String s
= new String(
String s =
new String(
index == bytes.length ? bytes : Arrays.copyOf(bytes, index),
StandardCharsets.UTF_8
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class JShellWrapperStartupScriptTest {
@Test
void testDoubleSnippets() {
Config config = new Config(5, 1024);
StringInputStream inputStream
= new StringInputStream(
StringInputStream inputStream =
new StringInputStream(
"""
import java.util.*; void println(Object o) { System.out.println(o); }
eval
Expand Down
2 changes: 1 addition & 1 deletion spotless.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
Expand Down

0 comments on commit e31f71f

Please sign in to comment.