Skip to content

Commit b4604cf

Browse files
committed
Optimize code
1 parent d712d3c commit b4604cf

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

instrumentation/apache-elasticjob-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/EmbedZookeeperServer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ public static void start(int port) {
1717
try {
1818
testingServer =
1919
new TestingServer(
20-
port, new File(String.format("target/test_zk_data/%s/", System.nanoTime())));
21-
} catch (Exception ex) {
22-
throw new RuntimeException("Failed to start embedded ZooKeeper server", ex);
20+
port, new File(String.format("build/test_zk_data/%s/", System.nanoTime())));
21+
} catch (Exception e) {
22+
throw new RuntimeException("Failed to start embedded ZooKeeper server", e);
2323
}
2424
}
2525

2626
public static void stop() {
2727
if (testingServer != null) {
2828
try {
2929
testingServer.close();
30-
} catch (IOException ex) {
31-
throw new RuntimeException("Failed to stop embedded ZooKeeper server", ex);
30+
} catch (IOException e) {
31+
throw new RuntimeException("Failed to stop embedded ZooKeeper server", e);
3232
}
3333
}
3434
}

instrumentation/apache-elasticjob-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/TestDataflowJob.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
package io.opentelemetry.javaagent.instrumentation.apacheelasticjob.v3_0;
77

8-
import java.util.Arrays;
8+
import static java.util.Arrays.asList;
9+
910
import java.util.List;
1011
import org.apache.shardingsphere.elasticjob.api.ShardingContext;
1112
import org.apache.shardingsphere.elasticjob.dataflow.job.DataflowJob;
@@ -17,11 +18,11 @@ public List<String> fetchData(ShardingContext context) {
1718
// Simulate fetching data based on sharding item
1819
switch (context.getShardingItem()) {
1920
case 0:
20-
return Arrays.asList("data-0-1", "data-0-2");
21+
return asList("data-0-1", "data-0-2");
2122
case 1:
22-
return Arrays.asList("data-1-1", "data-1-2");
23+
return asList("data-1-1", "data-1-2");
2324
default:
24-
return Arrays.asList("data-default");
25+
return asList("data-default");
2526
}
2627
}
2728

instrumentation/apache-elasticjob-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/TestFailedJob.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class TestFailedJob implements SimpleJob {
1212

1313
@Override
1414
public void execute(ShardingContext context) {
15-
// Simulate a failed job by throwing an exception
1615
throw new RuntimeException("Simulated job failure for testing");
1716
}
1817
}

instrumentation/apache-elasticjob-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheelasticjob/v3_0/TestSimpleJob.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class TestSimpleJob implements SimpleJob {
1212

1313
@Override
1414
public void execute(ShardingContext context) {
15-
// Simulate some work
1615
try {
1716
Thread.sleep(100);
1817
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)