diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-01-02 21:16:20 +0100 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2017-01-02 21:16:20 +0100 |
commit | 7fd9ac0bbd105be0b25512a9adf91f13f9d99a57 (patch) | |
tree | 51bfdb6bdaa987fc9f02e550b1ea076762c937dc /configserver | |
parent | 56d6dfc54ad94076a8c8698f02af773297946d2e (diff) |
Create new exception class to avoid using http exception class where it shold not be used
Diffstat (limited to 'configserver')
7 files changed, 18 insertions, 8 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 802942c5833..698e7baaaf0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -18,7 +18,6 @@ import com.yahoo.vespa.config.server.application.LogServerLogGrabber; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.Deployment; import com.yahoo.vespa.config.server.http.ContentHandler; -import com.yahoo.vespa.config.server.http.NotFoundException; import com.yahoo.vespa.config.server.http.v2.ApplicationContentRequest; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; import com.yahoo.vespa.config.server.session.LocalSession; @@ -181,7 +180,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return session.ensureApplicationLoaded().getForVersionOrLatest(Optional.empty()); } - // TODO: Don't use the NotFoundException here public LocalSession getLocalSession(Tenant tenant, long sessionId) { LocalSession session = tenant.getLocalSessionRepo().getSession(sessionId); if (session == null) throw new NotFoundException("Session " + sessionId + " was not found"); @@ -189,7 +187,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return session; } - // TODO: Don't use the NotFoundException here public RemoteSession getRemoteSession(Tenant tenant, long sessionId) { RemoteSession session = tenant.getRemoteSessionRepo().getSession(sessionId); if (session == null) throw new NotFoundException("Session " + sessionId + " was not found"); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/NotFoundException.java b/configserver/src/main/java/com/yahoo/vespa/config/server/NotFoundException.java new file mode 100644 index 00000000000..8da3752dffb --- /dev/null +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/NotFoundException.java @@ -0,0 +1,13 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.config.server; + +/** + * No resource found + * @author musum + * @since 6.55 + */ +public class NotFoundException extends IllegalArgumentException { + public NotFoundException(String s) { + super(s); + } +} diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java index af458b913cf..7da90a55228 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java @@ -8,7 +8,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; -import com.yahoo.vespa.config.server.http.NotFoundException; +import com.yahoo.vespa.config.server.NotFoundException; /** * Used during config request handling to route to the right config model diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java index 1858de94ca1..77fd35f9c0a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java @@ -44,7 +44,7 @@ public class HttpHandler extends LoggingRequestHandler { default: return createErrorResponse(request.getMethod()); } - } catch (NotFoundException e) { + } catch (NotFoundException | com.yahoo.vespa.config.server.NotFoundException e) { return HttpErrorResponse.notFoundError(getMessage(e, request)); } catch (BadRequestException e) { return HttpErrorResponse.badRequest(getMessage(e, request)); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java index 25eb2fa7961..51fd610affd 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java @@ -5,7 +5,7 @@ import com.yahoo.transaction.AbstractTransaction; import com.yahoo.transaction.NestedTransaction; import com.yahoo.transaction.Transaction; import com.yahoo.vespa.config.server.TimeoutBudget; -import com.yahoo.vespa.config.server.http.NotFoundException; +import com.yahoo.vespa.config.server.NotFoundException; import java.time.Clock; import java.time.Duration; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java index 88659798575..b47681a7e86 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java @@ -7,6 +7,7 @@ import com.yahoo.config.provision.Version; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.*; import com.yahoo.vespa.config.protocol.ConfigResponse; +import com.yahoo.vespa.config.server.NotFoundException; import com.yahoo.vespa.config.server.application.ApplicationMapper; import com.yahoo.vespa.config.server.application.ApplicationSet; import com.yahoo.vespa.config.server.rpc.ConfigResponseFactory; @@ -20,7 +21,6 @@ import com.yahoo.vespa.config.server.application.VersionDoesNotExistException; import com.yahoo.vespa.config.server.application.Application; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.http.NotFoundException; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.server.monitoring.Metrics; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java index db13e67072e..a474d21f161 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java @@ -8,7 +8,7 @@ import java.util.Optional; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Version; import com.yahoo.vespa.config.server.ModelStub; -import com.yahoo.vespa.config.server.http.NotFoundException; +import com.yahoo.vespa.config.server.NotFoundException; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import org.junit.Before; import org.junit.Test; |