Skip to content

Commit

Permalink
Merge pull request #32263 from vespa-engine/balder/avoid-java21-this-…
Browse files Browse the repository at this point in the history
…escape-warning-16

Balder/avoid java21 this escape warning 16
  • Loading branch information
jonmv authored Aug 26, 2024
2 parents 61e02db + c6f38af commit ca9f8af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
public abstract class RedirectedAsyncOperation<S, T> implements AsyncOperation<T> {

protected final AsyncOperation<S> source;
private final AsyncOperationListenImpl<T> listenImpl;
private AsyncOperationListenImpl<T> listenImpl;

public RedirectedAsyncOperation(AsyncOperation<S> source) {
this.source = source;
}

void listen() {
this.listenImpl = new AsyncOperationListenImpl<>(this);
source.register(new AsyncCallback<S>() {
@Override
public void done(AsyncOperation<S> op) { notifyDone(); }
});
source.register(op -> notifyDone());
}

private void notifyDone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class JsonHttpResult extends HttpResult {
public final class JsonHttpResult extends HttpResult {

private static final ObjectMapper mapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ public void done(AsyncOperation<String> op) {
void testRedirectedOperation() {
{
final AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test", "desc");
AsyncOperation<Integer> deleteRequest = new RedirectedAsyncOperation<String, Integer>(op) {
var deleteRequest = new RedirectedAsyncOperation<String, Integer>(op) {
@Override
public Integer getResult() {
return Integer.valueOf(op.getResult());
}
};
deleteRequest.listen();
final LinkedList<Integer> result = new LinkedList<>();
deleteRequest.register(new AsyncCallback<Integer>() {
@Override
Expand All @@ -134,12 +135,13 @@ public void done(AsyncOperation<Integer> op) {
}
{
final AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test", "desc");
AsyncOperation<Integer> deleteRequest = new RedirectedAsyncOperation<String, Integer>(op) {
var deleteRequest = new RedirectedAsyncOperation<String, Integer>(op) {
@Override
public Integer getResult() {
return Integer.valueOf(op.getResult());
}
};
deleteRequest.listen();
op.setFailure(new Exception("foo"));
assertTrue(deleteRequest.isDone());
assertEquals("foo", deleteRequest.getCause().getMessage());
Expand Down Expand Up @@ -182,7 +184,7 @@ public void successfullyDone(AsyncOperation<String> source) {
}
}

private abstract class StressThread implements Runnable {
private abstract static class StressThread implements Runnable {
private final Object monitor;
private boolean running = true;

Expand Down Expand Up @@ -210,20 +212,20 @@ public void run() {
public abstract void doTask();
}

private abstract class AsyncOpStressThread extends StressThread {
private abstract static class AsyncOpStressThread extends StressThread {
public AsyncOperationImpl<String> op;
public AsyncOpStressThread(Object monitor) { super(monitor); }
@Override
public boolean hasTask() { return op != null; }
}

private class Completer extends AsyncOpStressThread {
private static class Completer extends AsyncOpStressThread {
public Completer(Object monitor) { super(monitor); }
@Override
public void doTask() { op.setResult("foo"); op = null; }
}

private class Listener extends AsyncOpStressThread implements AsyncCallback<String> {
private static class Listener extends AsyncOpStressThread implements AsyncCallback<String> {
int counter = 0;
int unset = 0;
int priorReg = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author mortent
*/
public class DataplaneProxyService extends AbstractComponent {
public final class DataplaneProxyService extends AbstractComponent {

private static final Logger logger = Logger.getLogger(DataplaneProxyService.class.getName());
private static final String PREFIX = "/opt/vespa";
Expand Down

0 comments on commit ca9f8af

Please sign in to comment.