Skip to content

Commit

Permalink
bug:throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerWang committed May 17, 2022
1 parent 03ac2d9 commit 5f40408
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>nicer.djudger</groupId>
<artifactId>adapter</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>nicer.djudger</groupId>
<artifactId>adapter</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
6 changes: 3 additions & 3 deletions adapter/src/main/java/djudger/allocator/Allocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void run() {

protected abstract void removeAllContainers();

public final Task runCode(String language, List<String> commands, Integer timeLimit, TimeUnit timeUnit, String codeIdentifier, String code) throws Throwable {
public final Task runCode(String language, List<String> commands, Integer timeLimit, TimeUnit timeUnit, String codeIdentifier, String code) throws DJudgerException {
if (stopped) throw new DJudgerException("DJudger has stopped");

LangConfig target = langConfigMap.get(language);
Expand All @@ -64,7 +64,7 @@ public final Task runCode(String language, List<String> commands, Integer timeLi
return task;
}

protected Task preProcess(String language, String fileName, List<String> rawCommands, String codeIdentifier, String code, LangConfig target) throws Throwable {
protected Task preProcess(String language, String fileName, List<String> rawCommands, String codeIdentifier, String code, LangConfig target) throws DJudgerException {
if (language == null || rawCommands == null || codeIdentifier == null || code == null || rawCommands.size() == 0 || codeIdentifier.length() == 0 || code.length() == 0) {
throw new IllegalArgumentException("No Args should be null");
}
Expand All @@ -86,7 +86,7 @@ protected Task preProcess(String language, String fileName, List<String> rawComm
try {
FileUtil.writeCode(hostDirectory, hostFilePath, code);
} catch (IOException e) {
throw new DJudgerException("IO Error").initCause(e);
throw new DJudgerException("IO Error");
}
task.setRemotePath("/code/" + language);
task.setHostPath(hostDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public class ClassicAllocator extends Allocator {

public ClassicAllocator(Config config) {
super(config);
classicAllocatorConfig = (ClassicAllocatorConfig) config.allocatorConfig;
if(!(config.allocatorConfig instanceof ClassicAllocatorConfig)){
classicAllocatorConfig = new ClassicAllocatorConfig();
}
else classicAllocatorConfig = (ClassicAllocatorConfig) config.allocatorConfig;
for (LangConfig langConfig : langConfigMap.values()) {
langMap.put(langConfig.languageName, new Lang());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import djudger.LangConfig;
import djudger.Task;
import djudger.allocator.Allocator;
import djudger.allocator.classic.ClassicAllocator;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -20,7 +21,10 @@ public class ThreadPoolAllocator extends Allocator {

public ThreadPoolAllocator(Config config) {
super(config);
threadPoolAllocatorConfig = (ThreadPoolAllocatorConfig) config.allocatorConfig;
if(!(config.allocatorConfig instanceof ThreadPoolAllocatorConfig)){
threadPoolAllocatorConfig = new ThreadPoolAllocatorConfig();
}
else threadPoolAllocatorConfig = (ThreadPoolAllocatorConfig) config.allocatorConfig;
for (LangConfig lang : langConfigMap.values()) {
executorMap.put(lang.languageName, new ThreadPoolExecutor(threadPoolAllocatorConfig.corePoolSize,
threadPoolAllocatorConfig.maximumPoolSize, threadPoolAllocatorConfig.keepAliveTime,
Expand Down

0 comments on commit 5f40408

Please sign in to comment.