diff --git a/modules/dcache/src/main/java/org/dcache/pool/nearline/NearlineStorageHandler.java b/modules/dcache/src/main/java/org/dcache/pool/nearline/NearlineStorageHandler.java index e63f7b9ca5f..7879fdfb469 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/nearline/NearlineStorageHandler.java +++ b/modules/dcache/src/main/java/org/dcache/pool/nearline/NearlineStorageHandler.java @@ -1,6 +1,6 @@ /* dCache - http://www.dcache.org/ * - * Copyright (C) 2014 - 2023 Deutsches Elektronen-Synchrotron + * Copyright (C) 2014 - 2024 Deutsches Elektronen-Synchrotron * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -519,7 +519,7 @@ private void addFromNearlineStorage(StorageInfoMessage message, NearlineStorage */ private abstract static class AbstractRequest implements Comparable> { - protected enum State {QUEUED, ACTIVE, CANCELED} + protected enum State {QUEUED, ACTIVE, CANCELED, REMOVED} private final List> callbacks = new ArrayList<>(); protected final long createdAt = System.currentTimeMillis(); @@ -644,7 +644,7 @@ public int compareTo(AbstractRequest o) { } public void removeFromQueue() { - State currentState = state.get(); + State currentState = state.getAndSet(State.REMOVED); switch (currentState) { case QUEUED: decQueued(); @@ -655,6 +655,9 @@ public void removeFromQueue() { case CANCELED: decCanceled(); break; + case REMOVED: + LOGGER.warn("Request {} was already removed from the queue.", this); + break; default: throw new RuntimeException(); }