Fix "Future is already done" error in VC
This commit is contained in:
parent
7310c62e4d
commit
55729bf3ff
@ -301,7 +301,7 @@ public class AdminController extends BaseController {
|
|||||||
@PostMapping("/repositorySettings")
|
@PostMapping("/repositorySettings")
|
||||||
public DeferredResult<RepositorySettings> saveRepositorySettings(@RequestBody RepositorySettings settings) throws ThingsboardException {
|
public DeferredResult<RepositorySettings> saveRepositorySettings(@RequestBody RepositorySettings settings) throws ThingsboardException {
|
||||||
accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.WRITE);
|
accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.WRITE);
|
||||||
settings.setLocalOnly(false); // overriding, since local repositories are supported only for testing
|
settings.setLocalOnly(false); // only to be used in tests
|
||||||
ListenableFuture<RepositorySettings> future = versionControlService.saveVersionControlSettings(getTenantId(), settings);
|
ListenableFuture<RepositorySettings> future = versionControlService.saveVersionControlSettings(getTenantId(), settings);
|
||||||
return wrapFuture(Futures.transform(future, savedSettings -> {
|
return wrapFuture(Futures.transform(future, savedSettings -> {
|
||||||
savedSettings.setPassword(null);
|
savedSettings.setPassword(null);
|
||||||
@ -330,7 +330,7 @@ public class AdminController extends BaseController {
|
|||||||
@Parameter(description = "A JSON value representing the Repository Settings.")
|
@Parameter(description = "A JSON value representing the Repository Settings.")
|
||||||
@RequestBody RepositorySettings settings) throws Exception {
|
@RequestBody RepositorySettings settings) throws Exception {
|
||||||
accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ);
|
accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ);
|
||||||
settings = checkNotNull(settings);
|
settings.setLocalOnly(false); // only to be used in tests
|
||||||
return wrapFuture(versionControlService.checkVersionControlAccess(getTenantId(), settings), vcRequestTimeout);
|
return wrapFuture(versionControlService.checkVersionControlAccess(getTenantId(), settings), vcRequestTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,4 +483,5 @@ public class AdminController extends BaseController {
|
|||||||
adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings);
|
adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings);
|
||||||
response.sendRedirect(prevUri);
|
response.sendRedirect(prevUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -311,7 +312,13 @@ public class DefaultGitVersionControlQueueService implements GitVersionControlQu
|
|||||||
}
|
}
|
||||||
return submitFuture;
|
return submitFuture;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Future is already done!");
|
try {
|
||||||
|
request.getFuture().get();
|
||||||
|
throw new RuntimeException("Failed to process the request");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Throwable cause = ExceptionUtils.getRootCause(e);
|
||||||
|
throw new RuntimeException(cause.getMessage(), cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,5 +569,6 @@ public class DefaultGitVersionControlQueueService implements GitVersionControlQu
|
|||||||
private CommitRequestMsg.Builder buildCommitRequest(CommitGitRequest commit) {
|
private CommitRequestMsg.Builder buildCommitRequest(CommitGitRequest commit) {
|
||||||
return CommitRequestMsg.newBuilder().setTxId(commit.getTxId().toString());
|
return CommitRequestMsg.newBuilder().setTxId(commit.getTxId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user