diff --git a/CHANGELOG.md b/CHANGELOG.md index a59bc351ca..ffffc21087 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Upgraded dependencies +- Refactored exceptions ## [2.8.3] - 2018-08-01 diff --git a/docker-compose.yml b/docker-compose.yml index d5bfc3d793..509198f665 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -45,7 +45,7 @@ services: - "2181:2181" kafka: - image: wurstmeister/kafka:1.1.0 + image: wurstmeister/kafka:2.11-1.1.1 network_mode: "host" ports: - "9092:9092" diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java index 7fd3d13bae..e52b989843 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java @@ -9,9 +9,8 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeSchema; import org.zalando.nakadi.domain.Version; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.EventTypeRepository; import org.zalando.nakadi.utils.TestUtils; @@ -100,12 +99,12 @@ public void whenEventExistsFindByNameReturnsSomething() throws Exception { } @Test(expected = NoSuchEventTypeException.class) - public void whenEventDoesntExistsFindByNameReturnsNothing() throws NakadiException { + public void whenEventDoesntExistsFindByNameReturnsNothing() { repository.findByName("inexisting-name"); } @Test - public void whenUpdateExistingEventTypeItUpdates() throws NakadiException, IOException { + public void whenUpdateExistingEventTypeItUpdates() throws IOException { final EventType eventType = buildDefaultEventType(); repository.saveEventType(eventType); @@ -135,7 +134,7 @@ public void whenUpdateExistingEventTypeItUpdates() throws NakadiException, IOExc } @Test - public void whenUpdateDifferentSchemaVersionThenInsertIt() throws NakadiException, IOException { + public void whenUpdateDifferentSchemaVersionThenInsertIt() throws IOException { final EventType eventType = buildDefaultEventType(); repository.saveEventType(eventType); @@ -151,7 +150,7 @@ public void whenUpdateDifferentSchemaVersionThenInsertIt() throws NakadiExceptio } @Test - public void whenListExistingEventTypesAreListed() throws NakadiException { + public void whenListExistingEventTypesAreListed() { final EventType eventType1 = buildDefaultEventType(); final EventType eventType2 = buildDefaultEventType(); diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/StorageDbRepositoryTest.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/StorageDbRepositoryTest.java index ba6fd27726..e5fabc6eae 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/StorageDbRepositoryTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/StorageDbRepositoryTest.java @@ -5,7 +5,7 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.runtime.NoStorageException; +import org.zalando.nakadi.exceptions.runtime.NoSuchStorageException; import org.zalando.nakadi.exceptions.runtime.StorageIsUsedException; import org.zalando.nakadi.utils.TestUtils; @@ -94,7 +94,7 @@ public void testStorageDeleted() throws Exception { assertFalse(repository.getStorage(storage.getId()).isPresent()); } - @Test(expected = NoStorageException.class) + @Test(expected = NoSuchStorageException.class) public void testDeleteNoneExistingStorage() throws Exception { repository.deleteStorage(randomUUID()); } diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java index bae9b0dec1..130fdb124b 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java @@ -8,7 +8,7 @@ import org.zalando.nakadi.config.JsonConfig; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.DuplicatedSubscriptionException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.util.HashGenerator; diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/EventStreamReadingAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/EventStreamReadingAT.java index 499fe06bc3..aaa04db1d4 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/EventStreamReadingAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/EventStreamReadingAT.java @@ -262,7 +262,7 @@ public void whenReachKeepAliveLimitThenStreamIsClosed() { } @Test(timeout = 5000) - public void whenGetEventsWithUknownTopicThenTopicNotFound() { + public void whenGetEventsWithUnknownTopicThenTopicNotFound() { given() .when() .get(createStreamEndpointUrl("blah-topic")) diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java index c5f9a0a449..0ba764fb80 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java @@ -18,7 +18,7 @@ import org.zalando.nakadi.domain.ResourceAuthorization; import org.zalando.nakadi.domain.ResourceAuthorizationAttribute; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.partitioning.PartitionStrategy; import org.zalando.nakadi.repository.kafka.KafkaTestHelper; import org.zalando.nakadi.utils.EventTypeTestBuilder; diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java index e68abd8ffa..44522e7bc1 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.springframework.http.HttpStatus; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.kafka.KafkaTestHelper; import org.zalando.nakadi.utils.EventTypeTestBuilder; import org.zalando.nakadi.view.Cursor; diff --git a/src/main/java/org/zalando/nakadi/config/NakadiConfig.java b/src/main/java/org/zalando/nakadi/config/NakadiConfig.java index 85fa3d489e..f1cf7f4fb6 100644 --- a/src/main/java/org/zalando/nakadi/config/NakadiConfig.java +++ b/src/main/java/org/zalando/nakadi/config/NakadiConfig.java @@ -14,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.zalando.nakadi.domain.DefaultStorage; import org.zalando.nakadi.domain.Storage; -import org.zalando.nakadi.exceptions.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; import org.zalando.nakadi.exceptions.runtime.DuplicatedStorageException; import org.zalando.nakadi.repository.db.StorageDbRepository; import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; diff --git a/src/main/java/org/zalando/nakadi/config/SecurityConfiguration.java b/src/main/java/org/zalando/nakadi/config/SecurityConfiguration.java index 81b10df382..012995bd59 100644 --- a/src/main/java/org/zalando/nakadi/config/SecurityConfiguration.java +++ b/src/main/java/org/zalando/nakadi/config/SecurityConfiguration.java @@ -4,7 +4,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpOutputMessage; import org.springframework.http.converter.HttpMessageConverter; @@ -20,22 +19,13 @@ import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; import org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint; import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices; -import org.springframework.security.web.firewall.FirewalledRequest; -import org.springframework.security.web.firewall.HttpFirewall; -import org.springframework.security.web.firewall.RequestRejectedException; -import org.springframework.security.web.firewall.StrictHttpFirewall; import org.zalando.stups.oauth2.spring.security.expression.ExtendedOAuth2WebSecurityExpressionHandler; -import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; import static org.springframework.http.HttpMethod.DELETE; import static org.springframework.http.HttpMethod.GET; @@ -199,141 +189,4 @@ public String getDetail() { } } - // TODO: REMOVE IT AFTER EVERYONE HAS NORMALIZED THEIR URLS - @Bean - public HttpFirewall allowUrlEncodedSlashHttpFirewall() { - return new AllowForwardSlashesStrictHttpFirewall(); - } - - // TODO: REMOVE IT AFTER EVERYONE HAS NORMALIZED THEIR URLS - private static class AllowForwardSlashesStrictHttpFirewall extends StrictHttpFirewall { - - private static final String ENCODED_PERCENT = "%25"; - private static final String PERCENT = "%"; - private static final List FORBIDDEN_ENCODED_PERIOD = - Collections.unmodifiableList(Arrays.asList("%2e", "%2E")); - private Set encodedUrlBlacklist = new HashSet<>(); - private Set decodedUrlBlacklist = new HashSet<>(); - - AllowForwardSlashesStrictHttpFirewall() { - super(); - this.encodedUrlBlacklist.add(ENCODED_PERCENT); - this.encodedUrlBlacklist.addAll(FORBIDDEN_ENCODED_PERIOD); - this.decodedUrlBlacklist.add(PERCENT); - } - - private static boolean containsOnlyPrintableAsciiCharacters(final String uri) { - final int length = uri.length(); - for (int i = 0; i < length; i++) { - final char c = uri.charAt(i); - if (c < '\u0020' || c > '\u007e') { - return false; - } - } - - return true; - } - - private static boolean encodedUrlContains(final HttpServletRequest request, final String value) { - if (valueContains(request.getContextPath(), value)) { - return true; - } - return valueContains(request.getRequestURI(), value); - } - - private static boolean decodedUrlContains(final HttpServletRequest request, final String value) { - if (valueContains(request.getServletPath(), value)) { - return true; - } - if (valueContains(request.getPathInfo(), value)) { - return true; - } - return false; - } - - private static boolean valueContains(final String value, final String contains) { - return value != null && value.contains(contains); - } - - @Override - public FirewalledRequest getFirewalledRequest(final HttpServletRequest request) - throws RequestRejectedException { - rejectedBlacklistedUrls(request); - - if (!isNormalized(request)) { - throw new RequestRejectedException("The request was rejected because the URL was not normalized."); - } - - final String requestUri = request.getRequestURI(); - if (!containsOnlyPrintableAsciiCharacters(requestUri)) { - throw new RequestRejectedException("The requestURI was rejected because it can only " + - "contain printable ASCII characters."); - } - return new FirewalledRequest(request) { - @Override - public void reset() { - } - }; - } - - private static boolean isNormalized(final HttpServletRequest request) { - if (!isNormalized(request.getRequestURI())) { - return false; - } - if (!isNormalized(request.getContextPath())) { - return false; - } - if (!isNormalized(request.getServletPath())) { - return false; - } - if (!isNormalized(request.getPathInfo())) { - return false; - } - return true; - } - - private static boolean isNormalized(final String path) { - if (path == null) { - return true; - } - - // ONLY THIS PART IS REMOVED, ALL OTHER CODE IS THE SAME AS IN StrictHttpFirewall - // if (path.indexOf("//") > -1) { - // return false; - // } - - for (int j = path.length(); j > 0;) { - final int i = path.lastIndexOf('/', j - 1); - final int gap = j - i; - - if (gap == 2 && path.charAt(i + 1) == '.') { - // ".", "/./" or "/." - return false; - } else if (gap == 3 && path.charAt(i + 1) == '.' && path.charAt(i + 2) == '.') { - return false; - } - - j = i; - } - - return true; - } - - private void rejectedBlacklistedUrls(final HttpServletRequest request) { - for (final String forbidden : this.encodedUrlBlacklist) { - if (encodedUrlContains(request, forbidden)) { - throw new RequestRejectedException("The request was rejected because the URL contained " + - "a potentially malicious String \"" + forbidden + "\""); - } - } - for (final String forbidden : this.decodedUrlBlacklist) { - if (decodedUrlContains(request, forbidden)) { - throw new RequestRejectedException("The request was rejected because the URL contained " + - "a potentially malicious String \"" + forbidden + "\""); - } - } - } - - } - } diff --git a/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java b/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java index 3a10cdb7ee..ab640408df 100644 --- a/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java +++ b/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java @@ -15,14 +15,13 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.NakadiCursorLag; import org.zalando.nakadi.domain.ShiftedNakadiCursor; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.runtime.NotFoundException; import org.zalando.nakadi.exceptions.runtime.CursorConversionException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.InvalidCursorOperation; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NotFoundException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.EventTypeRepository; import org.zalando.nakadi.service.AuthorizationValidator; @@ -83,7 +82,7 @@ public ResponseEntity getDistance(@PathVariable("eventTypeName") final String final Long distance = cursorOperationsService.calculateDistance(initialCursor, finalCursor); query.setDistance(distance); } catch (InternalNakadiException | ServiceTemporarilyUnavailableException e) { - throw new MyNakadiRuntimeException1("problem calculating cursors distance", e); + throw new NakadiBaseException("problem calculating cursors distance", e); } catch (final NoSuchEventTypeException e) { throw new NotFoundException("event type not found", e); } catch (final InvalidCursorException e) { @@ -151,7 +150,7 @@ private String clientErrorMessage(final InvalidCursorOperation.Reason reason) { "have matching partitions."; default: LOG.error("Unexpected invalid cursor operation reason " + reason); - throw new MyNakadiRuntimeException1(); + throw new NakadiBaseException(); } } @@ -168,7 +167,7 @@ private Function toNakadiCursor(final String eventTypeName return cursor -> { try { return cursorConverter.convert(eventTypeName, cursor); - } catch (final NakadiException | InvalidCursorException e) { + } catch (final InternalNakadiException | InvalidCursorException e) { throw new CursorConversionException("problem converting cursors", e); } }; @@ -180,7 +179,7 @@ private Function toShiftedNakadiCursor(final final NakadiCursor nakadiCursor = cursorConverter.convert(eventTypeName, cursor); return new ShiftedNakadiCursor(nakadiCursor.getTimeline(), nakadiCursor.getPartition(), nakadiCursor.getOffset(), cursor.getShift()); - } catch (final NakadiException | InvalidCursorException e) { + } catch (final InternalNakadiException | InvalidCursorException e) { throw new CursorConversionException("problem converting cursors", e); } }; diff --git a/src/main/java/org/zalando/nakadi/controller/CursorsController.java b/src/main/java/org/zalando/nakadi/controller/CursorsController.java index c6cfa26b49..941f5ab5de 100644 --- a/src/main/java/org/zalando/nakadi/controller/CursorsController.java +++ b/src/main/java/org/zalando/nakadi/controller/CursorsController.java @@ -15,14 +15,14 @@ import org.springframework.web.context.request.NativeWebRequest; import org.zalando.nakadi.domain.ItemsWrapper; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.CursorsAreEmptyException; import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.InvalidStreamIdException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.RequestInProgressException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.UnableProcessException; @@ -46,6 +46,8 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE; import static org.springframework.http.ResponseEntity.noContent; import static org.springframework.http.ResponseEntity.ok; @@ -81,7 +83,7 @@ public ItemsWrapper getCursors(@PathVariable("subscriptionId .map(cursor -> cursor.withToken(cursorTokenService.generateToken())) .collect(Collectors.toList()); return new ItemsWrapper<>(cursors); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { throw new NakadiRuntimeException(e); } } @@ -110,12 +112,15 @@ public ResponseEntity commitCursors(@PathVariable("subscriptionId") final Str } } catch (final NoSuchEventTypeException | InvalidCursorException e) { return create(Problem.valueOf(UNPROCESSABLE_ENTITY, e.getMessage()), request); + } catch (final NoSuchSubscriptionException e) { + LOG.error("Subscription not found", e); + return create(Problem.valueOf(NOT_FOUND, e.getMessage()), request); } catch (final ServiceTemporarilyUnavailableException e) { LOG.error("Failed to commit cursors", e); return create(Problem.valueOf(SERVICE_UNAVAILABLE, e.getMessage()), request); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { LOG.error("Failed to commit cursors", e); - return create(e.asProblem(), request); + return create(Problem.valueOf(INTERNAL_SERVER_ERROR, e.getMessage()), request); } } @@ -131,8 +136,8 @@ public ResponseEntity resetCursors( throw new UnableProcessException(e.getMessage()); } catch (final InvalidCursorException e) { return create(Problem.valueOf(UNPROCESSABLE_ENTITY, e.getMessage()), request); - } catch (final NakadiException e) { - return create(e.asProblem(), request); + } catch (final InternalNakadiException e) { + return create(Problem.valueOf(INTERNAL_SERVER_ERROR, e.getMessage()), request); } } diff --git a/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java b/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java index 24571576b6..f74b47c35d 100644 --- a/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java +++ b/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java @@ -16,10 +16,10 @@ import org.springframework.web.context.request.NativeWebRequest; import org.zalando.nakadi.domain.EventPublishResult; import org.zalando.nakadi.domain.EventPublishingStatus; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.EventTypeTimeoutException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.metrics.EventTypeMetricRegistry; import org.zalando.nakadi.metrics.EventTypeMetrics; @@ -35,6 +35,9 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE; import static org.springframework.http.ResponseEntity.status; import static org.springframework.web.bind.annotation.RequestMethod.POST; import static org.zalando.problem.spring.web.advice.Responses.create; @@ -110,13 +113,13 @@ private ResponseEntity postEventInternal(final String eventTypeName, return processJSONException(e, nativeWebRequest); } catch (final NoSuchEventTypeException e) { LOG.debug("Event type not found.", e.getMessage()); - return create(e.asProblem(), nativeWebRequest); + return create(Problem.valueOf(NOT_FOUND, e.getMessage()), nativeWebRequest); } catch (final EventTypeTimeoutException e) { LOG.debug("Failed to publish batch", e); - return create(Problem.valueOf(Response.Status.SERVICE_UNAVAILABLE, e.getMessage()), nativeWebRequest); - } catch (final NakadiException e) { + return create(Problem.valueOf(SERVICE_UNAVAILABLE, e.getMessage()), nativeWebRequest); + } catch (final InternalNakadiException e) { LOG.debug("Failed to publish batch", e); - return create(e.asProblem(), nativeWebRequest); + return create(Problem.valueOf(INTERNAL_SERVER_ERROR, e.getMessage()), nativeWebRequest); } finally { eventTypeMetrics.updateTiming(startingNanos, System.nanoTime()); } diff --git a/src/main/java/org/zalando/nakadi/controller/EventStreamController.java b/src/main/java/org/zalando/nakadi/controller/EventStreamController.java index 159b13cb09..d6a441d35a 100644 --- a/src/main/java/org/zalando/nakadi/controller/EventStreamController.java +++ b/src/main/java/org/zalando/nakadi/controller/EventStreamController.java @@ -25,12 +25,12 @@ import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.InvalidLimitException; import org.zalando.nakadi.exceptions.runtime.NoConnectionSlotsException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.UnparseableCursorException; import org.zalando.nakadi.metrics.MetricUtils; @@ -74,6 +74,7 @@ import static javax.ws.rs.core.Response.Status.PRECONDITION_FAILED; import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE; import static org.zalando.nakadi.metrics.MetricUtils.metricNameFor; +import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; @RestController public class EventStreamController { @@ -272,9 +273,11 @@ public StreamingResponseBody streamEvents( } catch (final ServiceTemporarilyUnavailableException e) { LOG.error("Error while trying to stream events.", e); writeProblemResponse(response, outputStream, SERVICE_UNAVAILABLE, e.getMessage()); - } catch (final NakadiException e) { + } catch (final InvalidLimitException e) { + writeProblemResponse(response, outputStream, UNPROCESSABLE_ENTITY, e.getMessage()); + } catch (final InternalNakadiException e) { LOG.error("Error while trying to stream events.", e); - writeProblemResponse(response, outputStream, e.asProblem()); + writeProblemResponse(response, outputStream, INTERNAL_SERVER_ERROR, e.getMessage()); } catch (final InvalidCursorException e) { writeProblemResponse(response, outputStream, PRECONDITION_FAILED, e.getMessage()); } catch (final AccessDeniedException e) { diff --git a/src/main/java/org/zalando/nakadi/controller/EventTypeController.java b/src/main/java/org/zalando/nakadi/controller/EventTypeController.java index 49a1929482..7d636ae474 100644 --- a/src/main/java/org/zalando/nakadi/controller/EventTypeController.java +++ b/src/main/java/org/zalando/nakadi/controller/EventTypeController.java @@ -19,10 +19,6 @@ import org.zalando.nakadi.domain.CleanupPolicy; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.NoSuchPartitionStrategyException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.ConflictException; import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; @@ -30,8 +26,11 @@ import org.zalando.nakadi.exceptions.runtime.EventTypeOptionsValidationException; import org.zalando.nakadi.exceptions.runtime.EventTypeUnavailableException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; import org.zalando.nakadi.exceptions.runtime.InvalidEventTypeException; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchPartitionStrategyException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.TopicConfigException; import org.zalando.nakadi.exceptions.runtime.TopicCreationException; @@ -43,7 +42,6 @@ import org.zalando.nakadi.service.EventTypeService; import org.zalando.nakadi.service.FeatureToggleService; import org.zalando.nakadi.service.Result; -import org.zalando.problem.MoreStatus; import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.Responses; @@ -55,6 +53,7 @@ import static org.springframework.http.ResponseEntity.status; import static org.zalando.nakadi.service.FeatureToggleService.Feature.DISABLE_EVENT_TYPE_CREATION; import static org.zalando.nakadi.service.FeatureToggleService.Feature.DISABLE_EVENT_TYPE_DELETION; +import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; @RestController @RequestMapping(value = "/event-types") @@ -111,7 +110,7 @@ public ResponseEntity create(@Valid @RequestBody final EventTypeBase eventTyp public ResponseEntity delete(@PathVariable("name") final String eventTypeName) throws EventTypeDeletionException, AccessDeniedException, - NoEventTypeException, + NoSuchEventTypeException, ConflictException, ServiceTemporarilyUnavailableException { if (featureToggleService.isFeatureEnabled(DISABLE_EVENT_TYPE_DELETION) @@ -134,7 +133,8 @@ public ResponseEntity update( InconsistentStateException, NakadiRuntimeException, ServiceTemporarilyUnavailableException, - UnableProcessException { + UnableProcessException, + NoSuchPartitionStrategyException{ if (errors.hasErrors()) { return Responses.create(new ValidationProblem(errors), request); } @@ -184,7 +184,7 @@ public ResponseEntity deletion(final EventTypeDeletionException excepti public ResponseEntity unableProcess(final UnableProcessException exception, final NativeWebRequest request) { LOG.debug(exception.getMessage(), exception); - return Responses.create(MoreStatus.UNPROCESSABLE_ENTITY, exception.getMessage(), request); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); } @ExceptionHandler(ConflictException.class) @@ -193,13 +193,6 @@ public ResponseEntity conflict(final ConflictException exception, final return Responses.create(Response.Status.CONFLICT, exception.getMessage(), request); } - @ExceptionHandler(NoEventTypeException.class) - public ResponseEntity noEventType(final NoEventTypeException exception, - final NativeWebRequest request) { - LOG.debug(exception.getMessage(), exception); - return Responses.create(Response.Status.NOT_FOUND, exception.getMessage(), request); - } - @ExceptionHandler(EventTypeUnavailableException.class) public ResponseEntity eventTypeUnavailable(final EventTypeUnavailableException exception, final NativeWebRequest request) { @@ -207,18 +200,11 @@ public ResponseEntity eventTypeUnavailable(final EventTypeUnavailableEx return Responses.create(Response.Status.SERVICE_UNAVAILABLE, exception.getMessage(), request); } - @ExceptionHandler(NakadiException.class) - public ResponseEntity nakadiException(final NakadiException exception, - final NativeWebRequest request) { - LOG.debug(exception.getMessage(), exception); - return Responses.create(exception.asProblem(), request); - } - @ExceptionHandler(NoSuchPartitionStrategyException.class) - public ResponseEntity noSuchPartitionStrategyException(final NakadiException exception, + public ResponseEntity noSuchPartitionStrategyException(final NoSuchPartitionStrategyException exception, final NativeWebRequest request) { LOG.debug(exception.getMessage(), exception); - return Responses.create(exception.asProblem(), request); + return Responses.create(Problem.valueOf(UNPROCESSABLE_ENTITY, exception.getMessage()), request); } @ExceptionHandler(DuplicatedEventTypeNameException.class) @@ -232,13 +218,13 @@ public ResponseEntity duplicatedEventTypeNameException(final Duplicated public ResponseEntity invalidEventTypeException(final InvalidEventTypeException exception, final NativeWebRequest request) { LOG.debug(exception.getMessage(), exception); - return Responses.create(Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY, exception.getMessage()), request); + return Responses.create(Problem.valueOf(UNPROCESSABLE_ENTITY, exception.getMessage()), request); } @ExceptionHandler(EventTypeOptionsValidationException.class) public ResponseEntity unableProcess(final EventTypeOptionsValidationException exception, final NativeWebRequest request) { LOG.debug(exception.getMessage(), exception); - return Responses.create(MoreStatus.UNPROCESSABLE_ENTITY, exception.getMessage(), request); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); } } diff --git a/src/main/java/org/zalando/nakadi/controller/ExceptionHandling.java b/src/main/java/org/zalando/nakadi/controller/ExceptionHandling.java index 2ada606512..604042b162 100644 --- a/src/main/java/org/zalando/nakadi/controller/ExceptionHandling.java +++ b/src/main/java/org/zalando/nakadi/controller/ExceptionHandling.java @@ -10,21 +10,30 @@ import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.NativeWebRequest; -import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; -import org.zalando.nakadi.exceptions.runtime.IllegalClientIdException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.runtime.TimelineException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; +import org.zalando.nakadi.exceptions.runtime.CompactionException; import org.zalando.nakadi.exceptions.runtime.CursorConversionException; import org.zalando.nakadi.exceptions.runtime.CursorsAreEmptyException; import org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; +import org.zalando.nakadi.exceptions.runtime.IllegalClientIdException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidPartitionKeyFieldsException; import org.zalando.nakadi.exceptions.runtime.LimitReachedException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NoStreamingSlotsAvailable; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchPartitionStrategyException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSchemaException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; +import org.zalando.nakadi.exceptions.runtime.TimelineException; import org.zalando.nakadi.exceptions.runtime.TopicCreationException; +import org.zalando.nakadi.exceptions.runtime.UnprocessableSubscriptionException; import org.zalando.problem.MoreStatus; import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.ProblemHandling; @@ -32,6 +41,9 @@ import javax.ws.rs.core.Response; +import static javax.ws.rs.core.Response.Status.CONFLICT; +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.NOT_IMPLEMENTED; import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; @@ -77,12 +89,6 @@ class and stacktrace like information. return Responses.create(Response.Status.BAD_REQUEST, message, request); } - @ExceptionHandler(NoEventTypeException.class) - public ResponseEntity noEventTypeException(final NoEventTypeException exception, - final NativeWebRequest request) { - return Responses.create(Response.Status.NOT_FOUND, exception.getMessage(), request); - } - @ExceptionHandler(AccessDeniedException.class) public ResponseEntity accessDeniedException(final AccessDeniedException exception, final NativeWebRequest request) { @@ -106,9 +112,8 @@ public ResponseEntity handleCursorsUnavailableException(final RuntimeEx public ResponseEntity handleExceptionWrapper(final NakadiRuntimeException exception, final NativeWebRequest request) throws Exception { final Throwable cause = exception.getCause(); - if (cause instanceof NakadiException) { - final NakadiException ne = (NakadiException) cause; - return Responses.create(ne.asProblem(), request); + if (cause instanceof InternalNakadiException) { + return Responses.create(INTERNAL_SERVER_ERROR, exception.getMessage(), request); } throw exception.getException(); } @@ -120,8 +125,8 @@ public ResponseEntity handleRepositoryProblem(final RepositoryProblemEx return Responses.create(Response.Status.SERVICE_UNAVAILABLE, exception.getMessage(), request); } - @ExceptionHandler(MyNakadiRuntimeException1.class) - public ResponseEntity handleInternalError(final MyNakadiRuntimeException1 exception, + @ExceptionHandler(NakadiBaseException.class) + public ResponseEntity handleInternalError(final NakadiBaseException exception, final NativeWebRequest request) { LOG.error("Unexpected problem occurred", exception); return Responses.create(Response.Status.INTERNAL_SERVER_ERROR, exception.getMessage(), request); @@ -132,9 +137,8 @@ public ResponseEntity handleTimelineException(final TimelineException e final NativeWebRequest request) { LOG.error(exception.getMessage(), exception); final Throwable cause = exception.getCause(); - if (cause instanceof NakadiException) { - final NakadiException ne = (NakadiException) cause; - return Responses.create(ne.asProblem(), request); + if (cause instanceof InternalNakadiException) { + return Responses.create(Problem.valueOf(INTERNAL_SERVER_ERROR, exception.getMessage()), request); } return Responses.create(Response.Status.SERVICE_UNAVAILABLE, exception.getMessage(), request); } @@ -179,9 +183,80 @@ public ResponseEntity handleDbWriteOperationsBlockedException( public ResponseEntity handleFeatureNotAvailable( final FeatureNotAvailableException ex, final NativeWebRequest request) { - LOG.debug(ex.getMessage(), ex); + LOG.debug(ex.getMessage()); return Responses.create(Problem.valueOf(NOT_IMPLEMENTED, ex.getMessage()), request); + } + + @ExceptionHandler(CompactionException.class) + public ResponseEntity handleCompactionException(final CompactionException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); + } + + @ExceptionHandler(EnrichmentException.class) + public ResponseEntity handleEnrichmentException(final EnrichmentException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); + } + + @ExceptionHandler(NoSuchPartitionStrategyException.class) + public ResponseEntity handleNoSuchPartitionStrategyException( + final NoSuchPartitionStrategyException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); + } + + @ExceptionHandler(PartitioningException.class) + public ResponseEntity handlePartitioningException(final PartitioningException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); + } + + @ExceptionHandler(InvalidPartitionKeyFieldsException.class) + public ResponseEntity handleInvalidPartitionKeyFieldsException( + final InvalidPartitionKeyFieldsException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); + } + + @ExceptionHandler(NoSuchEventTypeException.class) + public ResponseEntity handleNoSuchEventTypeException(final NoSuchEventTypeException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(NOT_FOUND, exception.getMessage(), request); + } + @ExceptionHandler(NoSuchSchemaException.class) + public ResponseEntity handleNoSuchSchemaException(final NoSuchSchemaException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(NOT_FOUND, exception.getMessage(), request); } + @ExceptionHandler(NoSuchSubscriptionException.class) + public ResponseEntity handleNoSuchSubscriptionException(final NoSuchSubscriptionException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(NOT_FOUND, exception.getMessage(), request); + } + + @ExceptionHandler(NoStreamingSlotsAvailable.class) + public ResponseEntity handleNoStreamingSlotsAvailable(final NoStreamingSlotsAvailable exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(CONFLICT, exception.getMessage(), request); + } + + @ExceptionHandler(UnprocessableSubscriptionException.class) + public ResponseEntity handleUnprocessableSubscriptionException( + final UnprocessableSubscriptionException exception, + final NativeWebRequest request) { + LOG.debug(exception.getMessage()); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); + } } diff --git a/src/main/java/org/zalando/nakadi/controller/PartitionsController.java b/src/main/java/org/zalando/nakadi/controller/PartitionsController.java index 55233a438a..19e37ac713 100644 --- a/src/main/java/org/zalando/nakadi/controller/PartitionsController.java +++ b/src/main/java/org/zalando/nakadi/controller/PartitionsController.java @@ -18,12 +18,11 @@ import org.zalando.nakadi.domain.PartitionEndStatistics; import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.InvalidCursorOperation; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.NotFoundException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.EventTypeRepository; @@ -46,6 +45,7 @@ import java.util.stream.Collectors; import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE; import static org.springframework.http.ResponseEntity.ok; import static org.zalando.problem.spring.web.advice.Responses.create; @@ -105,9 +105,9 @@ public ResponseEntity listPartitions(@PathVariable("name") final String event return ok().body(result); } catch (final NoSuchEventTypeException e) { return create(Problem.valueOf(NOT_FOUND, "topic not found"), request); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { LOG.error("Could not list partitions. Respond with SERVICE_UNAVAILABLE.", e); - return create(e.asProblem(), request); + return create(Problem.valueOf(SERVICE_UNAVAILABLE, e.getMessage()), request); } } @@ -132,9 +132,9 @@ public ResponseEntity getPartition( } } catch (final NoSuchEventTypeException e) { return create(Problem.valueOf(NOT_FOUND, "topic not found"), request); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { LOG.error("Could not get partition. Respond with SERVICE_UNAVAILABLE.", e); - return create(e.asProblem(), request); + return create(Problem.valueOf(SERVICE_UNAVAILABLE, e.getMessage()), request); } catch (final InvalidCursorException e) { return create(Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY, INVALID_CURSOR_MESSAGE), request); @@ -163,7 +163,7 @@ private CursorLag getCursorLag(final String eventTypeName, final String partitio .stream() .findFirst() .map(this::toCursorLag) - .orElseThrow(MyNakadiRuntimeException1::new); + .orElseThrow(NakadiBaseException::new); } private EventTypePartitionView getTopicPartition(final String eventTypeName, final String partition) diff --git a/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java b/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java index 4a4a56d368..b8d0faa9b8 100644 --- a/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java +++ b/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java @@ -16,14 +16,14 @@ import org.springframework.web.util.UriComponents; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.DuplicatedSubscriptionException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; -import org.zalando.nakadi.exceptions.runtime.NoSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.SubscriptionUpdateConflictException; import org.zalando.nakadi.exceptions.runtime.TooManyPartitionsException; +import org.zalando.nakadi.exceptions.runtime.UnprocessableSubscriptionException; import org.zalando.nakadi.exceptions.runtime.WrongInitialCursorsException; import org.zalando.nakadi.plugin.api.ApplicationService; import org.zalando.nakadi.problem.ValidationProblem; @@ -37,6 +37,7 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static org.springframework.http.HttpStatus.OK; import static org.zalando.nakadi.service.FeatureToggleService.Feature.DISABLE_SUBSCRIPTION_CREATION; @@ -69,7 +70,7 @@ public ResponseEntity createOrGetSubscription(@Valid @RequestBody final Subsc try { return ok(subscriptionService.getExistingSubscription(subscriptionBase)); - } catch (final NoSubscriptionException e) { + } catch (final NoSuchSubscriptionException e) { if (featureToggleService.isFeatureEnabled(DISABLE_SUBSCRIPTION_CREATION)) { return Responses.create(Response.Status.SERVICE_UNAVAILABLE, "Subscription creation is temporarily unavailable", request); @@ -79,6 +80,8 @@ public ResponseEntity createOrGetSubscription(@Valid @RequestBody final Subsc return prepareLocationResponse(subscription); } catch (final DuplicatedSubscriptionException ex) { throw new InconsistentStateException("Unexpected problem occurred when creating subscription", ex); + } catch (final NoSuchEventTypeException ex) { + throw new UnprocessableSubscriptionException(ex.getMessage()); } } } @@ -98,7 +101,7 @@ public ResponseEntity updateSubscription( } catch (final SubscriptionUpdateConflictException ex) { return Responses.create(MoreStatus.UNPROCESSABLE_ENTITY, ex.getMessage(), request); } catch (final NoSuchSubscriptionException ex) { - return Responses.create(ex.asProblem(), request); + return Responses.create(Problem.valueOf(NOT_FOUND, ex.getMessage()), request); } } @@ -116,10 +119,9 @@ private ResponseEntity prepareLocationResponse(final Subscription subscriptio } @ExceptionHandler({ - NoEventTypeException.class, WrongInitialCursorsException.class, TooManyPartitionsException.class}) - public ResponseEntity handleUnprocessableSubscription(final MyNakadiRuntimeException1 exception, + public ResponseEntity handleUnprocessableSubscription(final NakadiBaseException exception, final NativeWebRequest request) { LOG.debug("Error occurred when working with subscriptions", exception); return Responses.create(MoreStatus.UNPROCESSABLE_ENTITY, exception.getMessage(), request); diff --git a/src/main/java/org/zalando/nakadi/controller/SubscriptionController.java b/src/main/java/org/zalando/nakadi/controller/SubscriptionController.java index 3116a2029a..c23d7a5bad 100644 --- a/src/main/java/org/zalando/nakadi/controller/SubscriptionController.java +++ b/src/main/java/org/zalando/nakadi/controller/SubscriptionController.java @@ -14,10 +14,11 @@ import org.springframework.web.context.request.NativeWebRequest; import org.zalando.nakadi.domain.ItemsWrapper; import org.zalando.nakadi.domain.SubscriptionEventTypeStats; -import org.zalando.nakadi.exceptions.ErrorGettingCursorTimeLagException; -import org.zalando.nakadi.exceptions.NakadiException; +import org.zalando.nakadi.exceptions.runtime.ErrorGettingCursorTimeLagException; import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.TimeLagStatsTimeoutException; import org.zalando.nakadi.service.FeatureToggleService; @@ -83,18 +84,12 @@ public ResponseEntity deleteSubscription(@PathVariable("id") final String sub public ItemsWrapper getSubscriptionStats( @PathVariable("id") final String subscriptionId, @RequestParam(value = "show_time_lag", required = false, defaultValue = "false") final boolean showTimeLag) - throws NakadiException, InconsistentStateException, ServiceTemporarilyUnavailableException { + throws InconsistentStateException, + NoSuchEventTypeException, NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { final StatsMode statsMode = showTimeLag ? StatsMode.TIMELAG : StatsMode.NORMAL; return subscriptionService.getSubscriptionStat(subscriptionId, statsMode); } - @ExceptionHandler(NakadiException.class) - public ResponseEntity handleNakadiException(final NakadiException ex, - final NativeWebRequest request) { - LOG.debug(ex.getMessage(), ex); - return Responses.create(ex.asProblem(), request); - } - @ExceptionHandler(FeatureNotAvailableException.class) public ResponseEntity handleFeatureTurnedOff(final FeatureNotAvailableException ex, final NativeWebRequest request) { diff --git a/src/main/java/org/zalando/nakadi/controller/SubscriptionStreamController.java b/src/main/java/org/zalando/nakadi/controller/SubscriptionStreamController.java index 7abe9f8c62..5d9b261677 100644 --- a/src/main/java/org/zalando/nakadi/controller/SubscriptionStreamController.java +++ b/src/main/java/org/zalando/nakadi/controller/SubscriptionStreamController.java @@ -21,9 +21,10 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import org.zalando.nakadi.config.NakadiSettings; import org.zalando.nakadi.domain.Subscription; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoStreamingSlotsAvailable; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.SubscriptionPartitionConflictException; import org.zalando.nakadi.exceptions.runtime.WrongStreamParametersException; import org.zalando.nakadi.repository.db.SubscriptionDbRepository; @@ -38,7 +39,6 @@ import org.zalando.nakadi.service.subscription.SubscriptionValidationService; import org.zalando.nakadi.util.FlowIdUtils; import org.zalando.nakadi.view.UserStreamParameters; -import org.zalando.problem.MoreStatus; import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.Responses; @@ -46,12 +46,17 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import javax.ws.rs.core.Response; import java.io.IOException; import java.io.OutputStream; import java.util.concurrent.atomic.AtomicBoolean; +import static javax.ws.rs.core.Response.Status.CONFLICT; +import static javax.ws.rs.core.Response.Status.FORBIDDEN; +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE; import static org.zalando.nakadi.metrics.MetricUtils.metricNameForSubscription; +import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; @RestController public class SubscriptionStreamController { @@ -118,21 +123,23 @@ public void onException(final Exception ex) { headersSent = true; try { if (ex instanceof AccessDeniedException) { - writeProblemResponse(response, out, Problem.valueOf(Response.Status.FORBIDDEN, + writeProblemResponse(response, out, Problem.valueOf(FORBIDDEN, ((AccessDeniedException) ex).explain())); } else if (ex instanceof SubscriptionPartitionConflictException) { - writeProblemResponse(response, out, Problem.valueOf(Response.Status.CONFLICT, + writeProblemResponse(response, out, Problem.valueOf(CONFLICT, ex.getMessage())); } else if (ex instanceof WrongStreamParametersException) { - writeProblemResponse(response, out, Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY, + writeProblemResponse(response, out, Problem.valueOf(UNPROCESSABLE_ENTITY, ex.getMessage())); } else if (ex instanceof NoSuchSubscriptionException) { - writeProblemResponse(response, out, Problem.valueOf(Response.Status.NOT_FOUND, + writeProblemResponse(response, out, Problem.valueOf(NOT_FOUND, ex.getMessage())); - } else if (ex instanceof NakadiException) { - writeProblemResponse(response, out, ((NakadiException) ex).asProblem()); + } else if (ex instanceof InternalNakadiException) { + writeProblemResponse(response, out, Problem.valueOf(INTERNAL_SERVER_ERROR, ex.getMessage())); + } else if (ex instanceof NoStreamingSlotsAvailable) { + writeProblemResponse(response, out, Problem.valueOf(CONFLICT, ex.getMessage())); } else { - writeProblemResponse(response, out, Problem.valueOf(Response.Status.SERVICE_UNAVAILABLE, + writeProblemResponse(response, out, Problem.valueOf(SERVICE_UNAVAILABLE, "Failed to continue streaming")); } out.flush(); @@ -207,7 +214,7 @@ private StreamingResponseBody stream(final String subscriptionId, try { if (blacklistService.isSubscriptionConsumptionBlocked(subscriptionId, client.getClientId())) { writeProblemResponse(response, outputStream, - Problem.valueOf(Response.Status.FORBIDDEN, "Application or event type is blocked")); + Problem.valueOf(FORBIDDEN, "Application or event type is blocked")); return; } @@ -243,7 +250,7 @@ private void writeProblemResponse(final HttpServletResponse response, public ResponseEntity invalidEventTypeException(final WrongStreamParametersException exception, final NativeWebRequest request) { LOG.debug(exception.getMessage(), exception); - return Responses.create(MoreStatus.UNPROCESSABLE_ENTITY, exception.getMessage(), request); + return Responses.create(UNPROCESSABLE_ENTITY, exception.getMessage(), request); } } diff --git a/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java b/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java index 2541bcd32b..a3881b87f9 100644 --- a/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java +++ b/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.domain; import com.google.common.base.Preconditions; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; import org.zalando.nakadi.repository.kafka.KafkaCursor; import java.util.Objects; @@ -118,7 +118,7 @@ public static NakadiCursor of(final Timeline timeline, final String partition, f case KAFKA: return new NakadiKafkaCursor(timeline, partition, offset); default: - throw new MyNakadiRuntimeException1( + throw new NakadiBaseException( "Cursor storage type " + timeline.getStorage().getType() + " not supported"); } } diff --git a/src/main/java/org/zalando/nakadi/enrichment/Enrichment.java b/src/main/java/org/zalando/nakadi/enrichment/Enrichment.java index cfca6edc91..aa576f154d 100644 --- a/src/main/java/org/zalando/nakadi/enrichment/Enrichment.java +++ b/src/main/java/org/zalando/nakadi/enrichment/Enrichment.java @@ -7,7 +7,7 @@ import org.zalando.nakadi.domain.EventCategory; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; -import org.zalando.nakadi.exceptions.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; import org.zalando.nakadi.exceptions.runtime.InvalidEventTypeException; import java.util.HashSet; diff --git a/src/main/java/org/zalando/nakadi/enrichment/EnrichmentStrategy.java b/src/main/java/org/zalando/nakadi/enrichment/EnrichmentStrategy.java index 17283dea6d..c46f270856 100644 --- a/src/main/java/org/zalando/nakadi/enrichment/EnrichmentStrategy.java +++ b/src/main/java/org/zalando/nakadi/enrichment/EnrichmentStrategy.java @@ -2,7 +2,7 @@ import org.zalando.nakadi.domain.BatchItem; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; public interface EnrichmentStrategy { void enrich(BatchItem batchItem, EventType eventType) throws EnrichmentException; diff --git a/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java b/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java index 189fde06fc..9bb82a94cc 100644 --- a/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java +++ b/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java @@ -6,7 +6,7 @@ import org.json.JSONObject; import org.zalando.nakadi.domain.BatchItem; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; import org.zalando.nakadi.util.FlowIdUtils; public class MetadataEnrichmentStrategy implements EnrichmentStrategy { diff --git a/src/main/java/org/zalando/nakadi/exceptions/CompactionException.java b/src/main/java/org/zalando/nakadi/exceptions/CompactionException.java deleted file mode 100644 index ae87942474..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/CompactionException.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.zalando.nakadi.exceptions; - -public class CompactionException extends UnprocessableEntityException { - - public CompactionException(final String message) { - super(message); - } - -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/InternalNakadiException.java b/src/main/java/org/zalando/nakadi/exceptions/InternalNakadiException.java deleted file mode 100644 index 90415303ac..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/InternalNakadiException.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.zalando.nakadi.exceptions; - -import javax.ws.rs.core.Response; - -public class InternalNakadiException extends NakadiException { - public InternalNakadiException(final String message) { - super(message); - } - - public InternalNakadiException(final String msg, final Exception cause) { - super(msg, cause); - } - - public InternalNakadiException(final String msg, final String problemMessage, final Exception cause) { - super(msg, problemMessage, cause); - } - - @Override - protected Response.StatusType getStatus() { - return Response.Status.INTERNAL_SERVER_ERROR; - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/NakadiException.java b/src/main/java/org/zalando/nakadi/exceptions/NakadiException.java deleted file mode 100644 index 00a83c2ed9..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/NakadiException.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.zalando.nakadi.exceptions; - - -import org.apache.commons.lang3.StringUtils; -import org.zalando.problem.Problem; - -import javax.ws.rs.core.Response; - -public abstract class NakadiException extends Exception { - - private String problemMessage; - - public NakadiException(final String message) { - super(message); - } - - public NakadiException(final String msg, final Exception cause) { - super(msg, cause); - } - - public NakadiException(final String msg, final String problemMessage, final Exception cause) { - this(msg, cause); - setProblemMessage(problemMessage); - } - - public String getProblemMessage() { - return problemMessage; - } - - public void setProblemMessage(final String problemMessage) { - this.problemMessage = problemMessage; - } - - public Problem asProblem() { - final String detail = StringUtils.isNotBlank(problemMessage) ? problemMessage : getMessage(); - return Problem.valueOf(getStatus(), detail); - } - - protected abstract Response.StatusType getStatus(); - -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/NoStreamingSlotsAvailable.java b/src/main/java/org/zalando/nakadi/exceptions/NoStreamingSlotsAvailable.java deleted file mode 100644 index 9ebe84fdb1..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/NoStreamingSlotsAvailable.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.zalando.nakadi.exceptions; - -import javax.ws.rs.core.Response; - -public class NoStreamingSlotsAvailable extends NakadiException { - public NoStreamingSlotsAvailable(final int totalSlots) { - super("No free slots for streaming available. Total slots: " + totalSlots); - } - - @Override - protected Response.StatusType getStatus() { - return Response.Status.CONFLICT; - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/NoSuchEventTypeException.java b/src/main/java/org/zalando/nakadi/exceptions/NoSuchEventTypeException.java deleted file mode 100644 index f22d722baa..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/NoSuchEventTypeException.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.zalando.nakadi.exceptions; - -import javax.ws.rs.core.Response; - -public class NoSuchEventTypeException extends NakadiException { - public NoSuchEventTypeException(final String message) { - super(message); - } - - public NoSuchEventTypeException(final String msg, final Exception cause) { - super(msg, cause); - } - - @Override - protected Response.StatusType getStatus() { - return Response.Status.NOT_FOUND; - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/NoSuchPartitionStrategyException.java b/src/main/java/org/zalando/nakadi/exceptions/NoSuchPartitionStrategyException.java deleted file mode 100644 index adbf3a139c..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/NoSuchPartitionStrategyException.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.zalando.nakadi.exceptions; - -public class NoSuchPartitionStrategyException extends UnprocessableEntityException { - - public NoSuchPartitionStrategyException(final String message) { - super(message); - } - -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/NoSuchSchemaException.java b/src/main/java/org/zalando/nakadi/exceptions/NoSuchSchemaException.java deleted file mode 100644 index 631898000e..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/NoSuchSchemaException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.zalando.nakadi.exceptions; - -import javax.ws.rs.core.Response; - -public class NoSuchSchemaException extends NakadiException { - - public NoSuchSchemaException(final String message) { - super(message); - } - - public NoSuchSchemaException(final String msg, final Exception cause) { - super(msg, cause); - } - - @Override - protected Response.StatusType getStatus() { - return Response.Status.NOT_FOUND; - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/NoSuchSubscriptionException.java b/src/main/java/org/zalando/nakadi/exceptions/NoSuchSubscriptionException.java deleted file mode 100644 index cd788fdce9..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/NoSuchSubscriptionException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.zalando.nakadi.exceptions; - -import javax.ws.rs.core.Response; - -public class NoSuchSubscriptionException extends NakadiException { - - public NoSuchSubscriptionException(final String message) { - super(message); - } - - public NoSuchSubscriptionException(final String msg, final Exception cause) { - super(msg, cause); - } - - @Override - protected Response.StatusType getStatus() { - return Response.Status.NOT_FOUND; - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/PartitioningException.java b/src/main/java/org/zalando/nakadi/exceptions/PartitioningException.java deleted file mode 100644 index 63d1ada554..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/PartitioningException.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.zalando.nakadi.exceptions; - -public class PartitioningException extends UnprocessableEntityException { - public PartitioningException(final String message) { - super(message); - } - - public PartitioningException(final String msg, final Exception cause) { - super(msg, cause); - } - - public PartitioningException(final String msg, final String problemMessage, final Exception cause) { - super(msg, problemMessage, cause); - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/Try.java b/src/main/java/org/zalando/nakadi/exceptions/Try.java index fb87f1ef65..9b0cac27c4 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/Try.java +++ b/src/main/java/org/zalando/nakadi/exceptions/Try.java @@ -1,5 +1,8 @@ package org.zalando.nakadi.exceptions; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; + import java.util.Optional; import java.util.concurrent.Callable; import java.util.function.Function; @@ -95,6 +98,8 @@ public boolean isSuccess() { public T getOrThrow() { if (exception instanceof NakadiRuntimeException) { throw (NakadiRuntimeException) exception; + } else if (exception instanceof NakadiBaseException) { + throw (NakadiBaseException) exception; } throw new NakadiRuntimeException(exception); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/UnprocessableEntityException.java b/src/main/java/org/zalando/nakadi/exceptions/UnprocessableEntityException.java deleted file mode 100644 index 9b817ecdf8..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/UnprocessableEntityException.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.zalando.nakadi.exceptions; - -import org.zalando.problem.MoreStatus; - -import javax.ws.rs.core.Response; - -public class UnprocessableEntityException extends NakadiException { - public UnprocessableEntityException(final String message) { - super(message); - } - - public UnprocessableEntityException(final String msg, final Exception cause) { - super(msg, cause); - } - - public UnprocessableEntityException(final String msg, final String problemMessage, final Exception cause) { - super(msg, problemMessage, cause); - } - - @Override - protected Response.StatusType getStatus() { - return MoreStatus.UNPROCESSABLE_ENTITY; - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/AccessDeniedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/AccessDeniedException.java index f7771bacc4..c494b381f0 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/AccessDeniedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/AccessDeniedException.java @@ -3,7 +3,7 @@ import org.zalando.nakadi.plugin.api.authz.AuthorizationService; import org.zalando.nakadi.plugin.api.authz.Resource; -public class AccessDeniedException extends MyNakadiRuntimeException1 { +public class AccessDeniedException extends NakadiBaseException { private final Resource resource; private final AuthorizationService.Operation operation; diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/CompactionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/CompactionException.java new file mode 100644 index 0000000000..0555c78036 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/CompactionException.java @@ -0,0 +1,9 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class CompactionException extends NakadiBaseException { + + public CompactionException(final String message) { + super(message); + } + +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/ConflictException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/ConflictException.java index fda674780e..97f12b1928 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/ConflictException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/ConflictException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class ConflictException extends MyNakadiRuntimeException1 { +public class ConflictException extends NakadiBaseException { public ConflictException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/ConnectionSlotOccupiedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/ConnectionSlotOccupiedException.java index a832ffe4cf..fbbc93c47e 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/ConnectionSlotOccupiedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/ConnectionSlotOccupiedException.java @@ -1,4 +1,4 @@ package org.zalando.nakadi.exceptions.runtime; -public class ConnectionSlotOccupiedException extends MyNakadiRuntimeException1 { +public class ConnectionSlotOccupiedException extends NakadiBaseException { } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorConversionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorConversionException.java index 1e8564c883..cf9bf7ed0b 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorConversionException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorConversionException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class CursorConversionException extends MyNakadiRuntimeException1 { +public class CursorConversionException extends NakadiBaseException { public CursorConversionException(final String message, final Exception e) { super(message, e); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorsAreEmptyException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorsAreEmptyException.java index f51fcc795a..58dd633a7a 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorsAreEmptyException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/CursorsAreEmptyException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class CursorsAreEmptyException extends MyNakadiRuntimeException1 { +public class CursorsAreEmptyException extends NakadiBaseException { public CursorsAreEmptyException() { super("Cursors are empty"); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/DbWriteOperationsBlockedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/DbWriteOperationsBlockedException.java index eb4fbebf4b..9352601c13 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/DbWriteOperationsBlockedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/DbWriteOperationsBlockedException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class DbWriteOperationsBlockedException extends MyNakadiRuntimeException1 { +public class DbWriteOperationsBlockedException extends NakadiBaseException { public DbWriteOperationsBlockedException(final String message) { super(message); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedEventTypeNameException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedEventTypeNameException.java index 5675698358..10be80f2aa 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedEventTypeNameException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedEventTypeNameException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class DuplicatedEventTypeNameException extends MyNakadiRuntimeException1 { +public class DuplicatedEventTypeNameException extends NakadiBaseException { public DuplicatedEventTypeNameException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedStorageException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedStorageException.java index 6ec7a94f80..ca2464b93e 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedStorageException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedStorageException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class DuplicatedStorageException extends MyNakadiRuntimeException1 { +public class DuplicatedStorageException extends NakadiBaseException { public DuplicatedStorageException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedSubscriptionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedSubscriptionException.java index b8dfbedc55..4f1e7b03dc 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedSubscriptionException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedSubscriptionException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class DuplicatedSubscriptionException extends MyNakadiRuntimeException1 { +public class DuplicatedSubscriptionException extends NakadiBaseException { public DuplicatedSubscriptionException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedTimelineException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedTimelineException.java index 3d53a093e1..848ce0641a 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedTimelineException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/DuplicatedTimelineException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class DuplicatedTimelineException extends MyNakadiRuntimeException1 { +public class DuplicatedTimelineException extends NakadiBaseException { public DuplicatedTimelineException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/EnrichmentException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EnrichmentException.java similarity index 62% rename from src/main/java/org/zalando/nakadi/exceptions/EnrichmentException.java rename to src/main/java/org/zalando/nakadi/exceptions/runtime/EnrichmentException.java index 293fbab358..990902975f 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/EnrichmentException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EnrichmentException.java @@ -1,6 +1,6 @@ -package org.zalando.nakadi.exceptions; +package org.zalando.nakadi.exceptions.runtime; -public class EnrichmentException extends UnprocessableEntityException { +public class EnrichmentException extends NakadiBaseException { public EnrichmentException(final String msg, final Exception cause) { super(msg, cause); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/ErrorGettingCursorTimeLagException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/ErrorGettingCursorTimeLagException.java similarity index 73% rename from src/main/java/org/zalando/nakadi/exceptions/ErrorGettingCursorTimeLagException.java rename to src/main/java/org/zalando/nakadi/exceptions/runtime/ErrorGettingCursorTimeLagException.java index fe442242a0..0af37e820c 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/ErrorGettingCursorTimeLagException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/ErrorGettingCursorTimeLagException.java @@ -1,9 +1,8 @@ -package org.zalando.nakadi.exceptions; +package org.zalando.nakadi.exceptions.runtime; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; -public class ErrorGettingCursorTimeLagException extends MyNakadiRuntimeException1 { +public class ErrorGettingCursorTimeLagException extends NakadiBaseException { private final NakadiCursor failedCursor; diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventPublishingException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventPublishingException.java index 4798068041..e0bc7d82b0 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventPublishingException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventPublishingException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class EventPublishingException extends MyNakadiRuntimeException1 { +public class EventPublishingException extends NakadiBaseException { public EventPublishingException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeDeletionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeDeletionException.java index 1e8ace53ad..a9ff52d056 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeDeletionException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeDeletionException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class EventTypeDeletionException extends MyNakadiRuntimeException1 { +public class EventTypeDeletionException extends NakadiBaseException { public EventTypeDeletionException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeOptionsValidationException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeOptionsValidationException.java index 47288f648a..c26a5a92ce 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeOptionsValidationException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeOptionsValidationException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class EventTypeOptionsValidationException extends MyNakadiRuntimeException1 { +public class EventTypeOptionsValidationException extends NakadiBaseException { public EventTypeOptionsValidationException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeTimeoutException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeTimeoutException.java index 6047766269..3cabc9d821 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeTimeoutException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeTimeoutException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class EventTypeTimeoutException extends MyNakadiRuntimeException1 { +public class EventTypeTimeoutException extends NakadiBaseException { public EventTypeTimeoutException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeUnavailableException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeUnavailableException.java index 7cf3e0aa07..f6e06c4699 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeUnavailableException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventTypeUnavailableException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class EventTypeUnavailableException extends MyNakadiRuntimeException1 { +public class EventTypeUnavailableException extends NakadiBaseException { public EventTypeUnavailableException(final String message) { diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventValidationException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventValidationException.java index 43dd4c46e2..4ff1ad7093 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/EventValidationException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/EventValidationException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class EventValidationException extends MyNakadiRuntimeException1 { +public class EventValidationException extends NakadiBaseException { public EventValidationException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/FeatureNotAvailableException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/FeatureNotAvailableException.java index 2a34e66d28..fa968c1c73 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/FeatureNotAvailableException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/FeatureNotAvailableException.java @@ -2,7 +2,7 @@ import org.zalando.nakadi.service.FeatureToggleService; -public class FeatureNotAvailableException extends MyNakadiRuntimeException1 { +public class FeatureNotAvailableException extends NakadiBaseException { private final FeatureToggleService.Feature feature; public FeatureNotAvailableException(final String message, final FeatureToggleService.Feature feature) { diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/IllegalClientIdException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/IllegalClientIdException.java index bc56ecbb46..8c3c0bc518 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/IllegalClientIdException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/IllegalClientIdException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class IllegalClientIdException extends MyNakadiRuntimeException1 { +public class IllegalClientIdException extends NakadiBaseException { public IllegalClientIdException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/InconsistentStateException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InconsistentStateException.java index ba3bc8d709..98b4b62edc 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/InconsistentStateException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InconsistentStateException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class InconsistentStateException extends MyNakadiRuntimeException1 { +public class InconsistentStateException extends NakadiBaseException { public InconsistentStateException(final String msg, final Throwable cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/InternalNakadiException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InternalNakadiException.java new file mode 100644 index 0000000000..66c5ae64f5 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InternalNakadiException.java @@ -0,0 +1,11 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class InternalNakadiException extends NakadiBaseException { + public InternalNakadiException(final String message) { + super(message); + } + + public InternalNakadiException(final String msg, final Exception cause) { + super(msg, cause); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/InvalidCursorException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorException.java similarity index 95% rename from src/main/java/org/zalando/nakadi/exceptions/InvalidCursorException.java rename to src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorException.java index 88c12022ec..19db439a9e 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/InvalidCursorException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorException.java @@ -1,10 +1,10 @@ -package org.zalando.nakadi.exceptions; +package org.zalando.nakadi.exceptions.runtime; import org.zalando.nakadi.domain.CursorError; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.view.Cursor; -public class InvalidCursorException extends Exception { +public class InvalidCursorException extends NakadiBaseException { private final CursorError error; private final Cursor cursor; diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorOperation.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorOperation.java index b9244e543d..e997909a16 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorOperation.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidCursorOperation.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class InvalidCursorOperation extends MyNakadiRuntimeException1 { +public class InvalidCursorOperation extends NakadiBaseException { private final Reason reason; public enum Reason { diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidEventTypeException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidEventTypeException.java index 7f713053bb..d3780de91f 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidEventTypeException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidEventTypeException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class InvalidEventTypeException extends MyNakadiRuntimeException1 { +public class InvalidEventTypeException extends NakadiBaseException { public InvalidEventTypeException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidLimitException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidLimitException.java new file mode 100644 index 0000000000..707345cc15 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidLimitException.java @@ -0,0 +1,8 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class InvalidLimitException extends NakadiBaseException { + + public InvalidLimitException(final String message) { + super(message); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/InvalidPartitionKeyFieldsException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidPartitionKeyFieldsException.java similarity index 59% rename from src/main/java/org/zalando/nakadi/exceptions/InvalidPartitionKeyFieldsException.java rename to src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidPartitionKeyFieldsException.java index 016380b6e1..640c5226ba 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/InvalidPartitionKeyFieldsException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidPartitionKeyFieldsException.java @@ -1,4 +1,4 @@ -package org.zalando.nakadi.exceptions; +package org.zalando.nakadi.exceptions.runtime; public class InvalidPartitionKeyFieldsException extends PartitioningException { public InvalidPartitionKeyFieldsException(final String message) { @@ -9,7 +9,4 @@ public InvalidPartitionKeyFieldsException(final String msg, final Exception caus super(msg, cause); } - public InvalidPartitionKeyFieldsException(final String msg, final String problemMessage, final Exception cause) { - super(msg, problemMessage, cause); - } } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidStreamIdException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidStreamIdException.java index fec377a6a8..f7316272b7 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidStreamIdException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/InvalidStreamIdException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class InvalidStreamIdException extends MyNakadiRuntimeException1 { +public class InvalidStreamIdException extends NakadiBaseException { private final String streamId; diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/LimitReachedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/LimitReachedException.java index 176632da4a..9c1f02b129 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/LimitReachedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/LimitReachedException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class LimitReachedException extends MyNakadiRuntimeException1 { +public class LimitReachedException extends NakadiBaseException { public LimitReachedException(final String msg, final Throwable cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/MyNakadiRuntimeException1.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NakadiBaseException.java similarity index 53% rename from src/main/java/org/zalando/nakadi/exceptions/runtime/MyNakadiRuntimeException1.java rename to src/main/java/org/zalando/nakadi/exceptions/runtime/NakadiBaseException.java index 568bce1346..a3ca3a8ab1 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/MyNakadiRuntimeException1.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NakadiBaseException.java @@ -4,16 +4,16 @@ * Parent class for Nakadi runtime exceptions * Name NakadiRuntimeException was already taken for some kind of wrapper. This name is a nice alternative ;) */ -public class MyNakadiRuntimeException1 extends RuntimeException { +public class NakadiBaseException extends RuntimeException { - public MyNakadiRuntimeException1() { + public NakadiBaseException() { } - public MyNakadiRuntimeException1(final String message) { + public NakadiBaseException(final String message) { super(message); } - public MyNakadiRuntimeException1(final String message, final Throwable cause) { + public NakadiBaseException(final String message, final Throwable cause) { super(message, cause); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/NakadiRuntimeException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NakadiRuntimeException.java similarity index 89% rename from src/main/java/org/zalando/nakadi/exceptions/NakadiRuntimeException.java rename to src/main/java/org/zalando/nakadi/exceptions/runtime/NakadiRuntimeException.java index dcf88383d8..20313b178e 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/NakadiRuntimeException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NakadiRuntimeException.java @@ -1,4 +1,4 @@ -package org.zalando.nakadi.exceptions; +package org.zalando.nakadi.exceptions.runtime; /* This exception is meant to be caught and unwrap the real excpetion */ public class NakadiRuntimeException extends RuntimeException { diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoConnectionSlotsException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoConnectionSlotsException.java index f8934968cd..deb22eef1c 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoConnectionSlotsException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoConnectionSlotsException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class NoConnectionSlotsException extends MyNakadiRuntimeException1 { +public class NoConnectionSlotsException extends NakadiBaseException { public NoConnectionSlotsException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoEventTypeException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoEventTypeException.java deleted file mode 100644 index 438433dd7c..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoEventTypeException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.zalando.nakadi.exceptions.runtime; - -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; - -public class NoEventTypeException extends MyNakadiRuntimeException1 { - - public NoEventTypeException(final String msg) { - super(msg); - } - - public NoEventTypeException(final String message, final NoSuchEventTypeException e) { - super(message, e); - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoStorageException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoStorageException.java deleted file mode 100644 index c32d4262c8..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoStorageException.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.zalando.nakadi.exceptions.runtime; - -public class NoStorageException extends MyNakadiRuntimeException1 { - - public NoStorageException(final String msg) { - super(msg); - } - -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoStreamingSlotsAvailable.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoStreamingSlotsAvailable.java new file mode 100644 index 0000000000..9d99abccb1 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoStreamingSlotsAvailable.java @@ -0,0 +1,7 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class NoStreamingSlotsAvailable extends NakadiBaseException { + public NoStreamingSlotsAvailable(final int totalSlots) { + super("No free slots for streaming available. Total slots: " + totalSlots); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSubscriptionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSubscriptionException.java deleted file mode 100644 index 32a7900f1f..0000000000 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSubscriptionException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.zalando.nakadi.exceptions.runtime; - -public class NoSubscriptionException extends MyNakadiRuntimeException1 { - - public NoSubscriptionException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchEventTypeException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchEventTypeException.java new file mode 100644 index 0000000000..cd7e33a8ee --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchEventTypeException.java @@ -0,0 +1,11 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class NoSuchEventTypeException extends NakadiBaseException { + public NoSuchEventTypeException(final String message) { + super(message); + } + + public NoSuchEventTypeException(final String msg, final Exception cause) { + super(msg, cause); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchPartitionStrategyException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchPartitionStrategyException.java new file mode 100644 index 0000000000..5325918097 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchPartitionStrategyException.java @@ -0,0 +1,9 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class NoSuchPartitionStrategyException extends NakadiBaseException { + + public NoSuchPartitionStrategyException(final String message) { + super(message); + } + +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchSchemaException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchSchemaException.java new file mode 100644 index 0000000000..970878344f --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchSchemaException.java @@ -0,0 +1,13 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class NoSuchSchemaException extends NakadiBaseException { + + public NoSuchSchemaException(final String message) { + super(message); + } + + public NoSuchSchemaException(final String msg, final Exception cause) { + super(msg, cause); + } + +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchStorageException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchStorageException.java new file mode 100644 index 0000000000..9a23e92c53 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchStorageException.java @@ -0,0 +1,9 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class NoSuchStorageException extends NakadiBaseException { + + public NoSuchStorageException(final String msg) { + super(msg); + } + +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchSubscriptionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchSubscriptionException.java new file mode 100644 index 0000000000..a57c48923a --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NoSuchSubscriptionException.java @@ -0,0 +1,12 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class NoSuchSubscriptionException extends NakadiBaseException { + + public NoSuchSubscriptionException(final String message) { + super(message); + } + + public NoSuchSubscriptionException(final String msg, final Exception cause) { + super(msg, cause); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/NotFoundException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/NotFoundException.java index deac2c52ac..b82bc85156 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/NotFoundException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/NotFoundException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class NotFoundException extends MyNakadiRuntimeException1 { +public class NotFoundException extends NakadiBaseException { public NotFoundException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationInterruptedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationInterruptedException.java index 9b860a1be5..4f864604cb 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationInterruptedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationInterruptedException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class OperationInterruptedException extends MyNakadiRuntimeException1 { +public class OperationInterruptedException extends NakadiBaseException { public OperationInterruptedException(final String message, final Throwable cause) { super(message, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationTimeoutException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationTimeoutException.java index e8e598346c..af27d03f5b 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationTimeoutException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/OperationTimeoutException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class OperationTimeoutException extends MyNakadiRuntimeException1 { +public class OperationTimeoutException extends NakadiBaseException { public OperationTimeoutException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/PartitioningException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/PartitioningException.java new file mode 100644 index 0000000000..a786f729e1 --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/PartitioningException.java @@ -0,0 +1,11 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class PartitioningException extends NakadiBaseException { + public PartitioningException(final String message) { + super(message); + } + + public PartitioningException(final String msg, final Exception cause) { + super(msg, cause); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/RebalanceConflictException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/RebalanceConflictException.java index 60d29c255b..0b476eebc7 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/RebalanceConflictException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/RebalanceConflictException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class RebalanceConflictException extends MyNakadiRuntimeException1 { +public class RebalanceConflictException extends NakadiBaseException { public RebalanceConflictException(final String msg) { super(msg); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/RepositoryProblemException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/RepositoryProblemException.java index 6b268e5347..71856f93ce 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/RepositoryProblemException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/RepositoryProblemException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class RepositoryProblemException extends MyNakadiRuntimeException1 { +public class RepositoryProblemException extends NakadiBaseException { public RepositoryProblemException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/RequestInProgressException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/RequestInProgressException.java index 540915b887..ad1fb4a960 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/RequestInProgressException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/RequestInProgressException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class RequestInProgressException extends MyNakadiRuntimeException1 { +public class RequestInProgressException extends NakadiBaseException { public RequestInProgressException(final String message, final Throwable cause) { super(message, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/ServiceTemporarilyUnavailableException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/ServiceTemporarilyUnavailableException.java index a543c9a41e..80f187f1ae 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/ServiceTemporarilyUnavailableException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/ServiceTemporarilyUnavailableException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class ServiceTemporarilyUnavailableException extends MyNakadiRuntimeException1 { +public class ServiceTemporarilyUnavailableException extends NakadiBaseException { public ServiceTemporarilyUnavailableException(final Exception cause) { super(cause.getMessage(), cause); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/StorageIsUsedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/StorageIsUsedException.java index 1992c1efee..11bfb92cc6 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/StorageIsUsedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/StorageIsUsedException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class StorageIsUsedException extends MyNakadiRuntimeException1 { +public class StorageIsUsedException extends NakadiBaseException { public StorageIsUsedException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionPartitionConflictException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionPartitionConflictException.java index 1eca7c8571..c30b842657 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionPartitionConflictException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionPartitionConflictException.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.stream.Collectors; -public class SubscriptionPartitionConflictException extends MyNakadiRuntimeException1 { +public class SubscriptionPartitionConflictException extends NakadiBaseException { private SubscriptionPartitionConflictException(final String msg) { super(msg); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionUpdateConflictException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionUpdateConflictException.java index ebe50acf0c..2a54ab8c27 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionUpdateConflictException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/SubscriptionUpdateConflictException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class SubscriptionUpdateConflictException extends MyNakadiRuntimeException1 { +public class SubscriptionUpdateConflictException extends NakadiBaseException { public SubscriptionUpdateConflictException(final String message) { super(message); } diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TimeLagStatsTimeoutException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TimeLagStatsTimeoutException.java index 9eec9d7a5e..2da65922dd 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TimeLagStatsTimeoutException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TimeLagStatsTimeoutException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TimeLagStatsTimeoutException extends MyNakadiRuntimeException1 { +public class TimeLagStatsTimeoutException extends NakadiBaseException { public TimeLagStatsTimeoutException(final String msg, final Throwable cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelineException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelineException.java index 6830f97ba0..914c857872 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelineException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelineException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TimelineException extends MyNakadiRuntimeException1 { +public class TimelineException extends NakadiBaseException { public TimelineException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelinesNotSupportedException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelinesNotSupportedException.java index 5b4a8d08ff..4f7b71d74b 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelinesNotSupportedException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TimelinesNotSupportedException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TimelinesNotSupportedException extends MyNakadiRuntimeException1 { +public class TimelinesNotSupportedException extends NakadiBaseException { public TimelinesNotSupportedException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TooManyPartitionsException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TooManyPartitionsException.java index ee3faaf953..fe0083491c 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TooManyPartitionsException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TooManyPartitionsException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TooManyPartitionsException extends MyNakadiRuntimeException1 { +public class TooManyPartitionsException extends NakadiBaseException { public TooManyPartitionsException(final String msg) { super(msg); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicConfigException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicConfigException.java index a0379ed1d8..b9bcf80ae0 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicConfigException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicConfigException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TopicConfigException extends MyNakadiRuntimeException1 { +public class TopicConfigException extends NakadiBaseException { public TopicConfigException(final String message, final Exception e) { super(message, e); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicCreationException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicCreationException.java index 5913aa4e21..87efdeb37e 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicCreationException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicCreationException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TopicCreationException extends MyNakadiRuntimeException1 { +public class TopicCreationException extends NakadiBaseException { public TopicCreationException(final String msg) { super(msg); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicDeletionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicDeletionException.java index fb56e71dd4..e98c6f6362 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicDeletionException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicDeletionException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TopicDeletionException extends MyNakadiRuntimeException1 { +public class TopicDeletionException extends NakadiBaseException { public TopicDeletionException(final String msg, final Exception cause) { super(msg, cause); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicRepositoryException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicRepositoryException.java index cce6f570dc..afdfa62464 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicRepositoryException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/TopicRepositoryException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class TopicRepositoryException extends MyNakadiRuntimeException1 { +public class TopicRepositoryException extends NakadiBaseException { public TopicRepositoryException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnableProcessException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnableProcessException.java index 5e6af521a4..93d9abda84 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnableProcessException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnableProcessException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class UnableProcessException extends MyNakadiRuntimeException1 { +public class UnableProcessException extends NakadiBaseException { public UnableProcessException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownOperationException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownOperationException.java index 15abf9a159..1b30365196 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownOperationException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownOperationException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class UnknownOperationException extends MyNakadiRuntimeException1 { +public class UnknownOperationException extends NakadiBaseException { public UnknownOperationException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownStorageTypeException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownStorageTypeException.java index 603db17a1b..e292c6ec54 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownStorageTypeException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnknownStorageTypeException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class UnknownStorageTypeException extends MyNakadiRuntimeException1 { +public class UnknownStorageTypeException extends NakadiBaseException { public UnknownStorageTypeException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnparseableCursorException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnparseableCursorException.java index d257e0e7e0..62cef7f182 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnparseableCursorException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnparseableCursorException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class UnparseableCursorException extends MyNakadiRuntimeException1 { +public class UnparseableCursorException extends NakadiBaseException { private final String cursors; public UnparseableCursorException(final String msg, final Exception cause, final String cursors) { diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/UnprocessableSubscriptionException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnprocessableSubscriptionException.java new file mode 100644 index 0000000000..73df3e051e --- /dev/null +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/UnprocessableSubscriptionException.java @@ -0,0 +1,7 @@ +package org.zalando.nakadi.exceptions.runtime; + +public class UnprocessableSubscriptionException extends NakadiBaseException { + public UnprocessableSubscriptionException(final String message) { + super(message); + } +} diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongInitialCursorsException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongInitialCursorsException.java index 977524a9e4..2684c20ca8 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongInitialCursorsException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongInitialCursorsException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class WrongInitialCursorsException extends MyNakadiRuntimeException1 { +public class WrongInitialCursorsException extends NakadiBaseException { public WrongInitialCursorsException(final String msg) { super(msg); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongStreamParametersException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongStreamParametersException.java index b95549c8c7..13f390f222 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongStreamParametersException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/WrongStreamParametersException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class WrongStreamParametersException extends MyNakadiRuntimeException1 { +public class WrongStreamParametersException extends NakadiBaseException { public WrongStreamParametersException(final String message) { super(message); diff --git a/src/main/java/org/zalando/nakadi/exceptions/runtime/ZookeeperException.java b/src/main/java/org/zalando/nakadi/exceptions/runtime/ZookeeperException.java index eb656c8948..6592bd6bb1 100644 --- a/src/main/java/org/zalando/nakadi/exceptions/runtime/ZookeeperException.java +++ b/src/main/java/org/zalando/nakadi/exceptions/runtime/ZookeeperException.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.exceptions.runtime; -public class ZookeeperException extends MyNakadiRuntimeException1 { +public class ZookeeperException extends NakadiBaseException { public ZookeeperException(final String message, final Throwable cause) { super(message, cause); diff --git a/src/main/java/org/zalando/nakadi/partitioning/HashPartitionStrategy.java b/src/main/java/org/zalando/nakadi/partitioning/HashPartitionStrategy.java index 3e6f782514..e4db3da7cf 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/HashPartitionStrategy.java +++ b/src/main/java/org/zalando/nakadi/partitioning/HashPartitionStrategy.java @@ -5,8 +5,8 @@ import org.springframework.stereotype.Component; import org.zalando.nakadi.domain.EventCategory; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.InvalidPartitionKeyFieldsException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.Try; import org.zalando.nakadi.util.JsonPathAccess; import org.zalando.nakadi.validation.JsonSchemaEnrichment; diff --git a/src/main/java/org/zalando/nakadi/partitioning/PartitionResolver.java b/src/main/java/org/zalando/nakadi/partitioning/PartitionResolver.java index 3411a67c80..c55e31a09c 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/PartitionResolver.java +++ b/src/main/java/org/zalando/nakadi/partitioning/PartitionResolver.java @@ -7,8 +7,8 @@ import org.springframework.stereotype.Component; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; -import org.zalando.nakadi.exceptions.NoSuchPartitionStrategyException; -import org.zalando.nakadi.exceptions.PartitioningException; +import org.zalando.nakadi.exceptions.runtime.NoSuchPartitionStrategyException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import org.zalando.nakadi.exceptions.runtime.InvalidEventTypeException; import org.zalando.nakadi.service.timeline.TimelineService; diff --git a/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java b/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java index 681ccd8b5f..f43cabd64f 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java +++ b/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java @@ -2,7 +2,7 @@ import org.json.JSONObject; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.PartitioningException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java b/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java index 265d104e57..0a9e36f051 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java +++ b/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java @@ -3,7 +3,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.PartitioningException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/repository/EventConsumer.java b/src/main/java/org/zalando/nakadi/repository/EventConsumer.java index 4b27f7bdb0..119fbcc027 100644 --- a/src/main/java/org/zalando/nakadi/repository/EventConsumer.java +++ b/src/main/java/org/zalando/nakadi/repository/EventConsumer.java @@ -4,8 +4,7 @@ import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.TopicPartition; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import java.io.Closeable; import java.util.Collection; @@ -23,6 +22,6 @@ interface LowLevelConsumer extends EventConsumer { interface ReassignableEventConsumer extends EventConsumer { Set getAssignment(); - void reassign(Collection newValues) throws NakadiException, InvalidCursorException; + void reassign(Collection newValues) throws InvalidCursorException; } } diff --git a/src/main/java/org/zalando/nakadi/repository/EventTypeRepository.java b/src/main/java/org/zalando/nakadi/repository/EventTypeRepository.java index e7cbdd139e..c1a35d8580 100644 --- a/src/main/java/org/zalando/nakadi/repository/EventTypeRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/EventTypeRepository.java @@ -2,8 +2,8 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/repository/KafkaRepositoryCreator.java b/src/main/java/org/zalando/nakadi/repository/KafkaRepositoryCreator.java index 731bba8ef1..e047754e9c 100644 --- a/src/main/java/org/zalando/nakadi/repository/KafkaRepositoryCreator.java +++ b/src/main/java/org/zalando/nakadi/repository/KafkaRepositoryCreator.java @@ -7,7 +7,7 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.TopicRepositoryException; import org.zalando.nakadi.repository.kafka.KafkaFactory; import org.zalando.nakadi.repository.kafka.KafkaLocationManager; diff --git a/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java b/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java index 716af70a96..d0deb8fe4a 100644 --- a/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java +++ b/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java @@ -8,9 +8,8 @@ import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.domain.TopicPartition; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.service.timeline.TimelineSync; @@ -85,7 +84,7 @@ public List readEvents() { if (timelinesChanged.compareAndSet(true, false)) { try { onTimelinesChanged(); - } catch (final NakadiException | InvalidCursorException ex) { + } catch (final InvalidCursorException ex) { throw new NakadiRuntimeException(ex); } } @@ -177,7 +176,7 @@ private NakadiCursor getBeforeFirstCursor( " and partition " + partition + ", but it wasn't found")).getBeforeFirst(); } - private void electTopicRepositories() throws NakadiException, InvalidCursorException { + private void electTopicRepositories() throws InvalidCursorException { final Map> newAssignment = new HashMap<>(); borderOffsets.clear(); // Purpose of this collection is to hold tr that definitely changed their positions and should be recreated. @@ -244,7 +243,7 @@ private void stopAndRemoveConsumer(final TopicRepository toRemove) { } - private void onTimelinesChanged() throws NakadiException, InvalidCursorException { + private void onTimelinesChanged() throws InvalidCursorException { final Set eventTypes = latestOffsets.values().stream() .map(NakadiCursor::getEventType) .collect(Collectors.toSet()); @@ -265,7 +264,7 @@ private void onTimelinesChanged() throws NakadiException, InvalidCursorException } @Override - public void reassign(final Collection newValues) throws NakadiException, InvalidCursorException { + public void reassign(final Collection newValues) throws InvalidCursorException { final Map newCursorMap = newValues.stream() .collect(Collectors.toMap(NakadiCursor::getEventTypePartition, Function.identity())); @@ -308,7 +307,7 @@ void onTimelineChange(final String eventType) { public void close() throws IOException { try { reassign(Collections.emptySet()); - } catch (final NakadiException | InvalidCursorException e) { + } catch (final InvalidCursorException e) { throw new IOException(e); } } diff --git a/src/main/java/org/zalando/nakadi/repository/TopicRepository.java b/src/main/java/org/zalando/nakadi/repository/TopicRepository.java index cb0c55a78a..02033448ee 100644 --- a/src/main/java/org/zalando/nakadi/repository/TopicRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/TopicRepository.java @@ -5,9 +5,8 @@ import org.zalando.nakadi.domain.PartitionEndStatistics; import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; import org.zalando.nakadi.exceptions.runtime.EventPublishingException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.TopicConfigException; import org.zalando.nakadi.exceptions.runtime.TopicCreationException; @@ -69,7 +68,7 @@ List loadTopicEndStatistics(Collection topics) List listPartitionNames(String topicId); EventConsumer.LowLevelConsumer createEventConsumer(String clientId, List positions) - throws NakadiException, InvalidCursorException; + throws InvalidCursorException; void validateReadCursors(List cursors) throws InvalidCursorException, ServiceTemporarilyUnavailableException; diff --git a/src/main/java/org/zalando/nakadi/repository/TopicRepositoryCreator.java b/src/main/java/org/zalando/nakadi/repository/TopicRepositoryCreator.java index acae318b10..fd6472b8bd 100644 --- a/src/main/java/org/zalando/nakadi/repository/TopicRepositoryCreator.java +++ b/src/main/java/org/zalando/nakadi/repository/TopicRepositoryCreator.java @@ -3,7 +3,7 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.TopicRepositoryException; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/repository/TopicRepositoryHolder.java b/src/main/java/org/zalando/nakadi/repository/TopicRepositoryHolder.java index f7c9d708d5..00c60a7e03 100644 --- a/src/main/java/org/zalando/nakadi/repository/TopicRepositoryHolder.java +++ b/src/main/java/org/zalando/nakadi/repository/TopicRepositoryHolder.java @@ -9,7 +9,7 @@ import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.TopicRepositoryException; diff --git a/src/main/java/org/zalando/nakadi/repository/db/CachingEventTypeRepository.java b/src/main/java/org/zalando/nakadi/repository/db/CachingEventTypeRepository.java index 401b6eb5a8..06bd41bfa5 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/CachingEventTypeRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/CachingEventTypeRepository.java @@ -8,8 +8,8 @@ import org.zalando.nakadi.annotations.DB; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; import org.zalando.nakadi.repository.EventTypeRepository; diff --git a/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java b/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java index bc11bb847d..8d7b77cc72 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java +++ b/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java @@ -5,6 +5,7 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; +import com.google.common.util.concurrent.UncheckedExecutionException; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.PathChildrenCache; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; @@ -15,8 +16,8 @@ import org.slf4j.LoggerFactory; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.EventTypeRepository; import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; import org.zalando.nakadi.service.timeline.TimelineSync; @@ -161,7 +162,7 @@ private Optional getCached(final String name) throws NoSuchEventTypeException, InternalNakadiException { try { return Optional.ofNullable(eventTypeCache.get(name)); - } catch (final ExecutionException e) { + } catch (final UncheckedExecutionException | ExecutionException e) { if (e.getCause() instanceof NoSuchEventTypeException) { throw (NoSuchEventTypeException) e.getCause(); } else { diff --git a/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java b/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java index 219055038c..3a0edafdf1 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java @@ -15,8 +15,8 @@ import org.zalando.nakadi.annotations.DB; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; import org.zalando.nakadi.repository.EventTypeRepository; diff --git a/src/main/java/org/zalando/nakadi/repository/db/SchemaRepository.java b/src/main/java/org/zalando/nakadi/repository/db/SchemaRepository.java index 958a0e70f2..e776f84bc2 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/SchemaRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/SchemaRepository.java @@ -7,7 +7,7 @@ import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; import org.zalando.nakadi.domain.EventTypeSchema; -import org.zalando.nakadi.exceptions.NoSuchSchemaException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSchemaException; import java.io.IOException; import java.sql.ResultSet; diff --git a/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java b/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java index e79e6343ff..9611453cf5 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java @@ -12,7 +12,7 @@ import org.zalando.nakadi.annotations.DB; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.exceptions.runtime.DuplicatedStorageException; -import org.zalando.nakadi.exceptions.runtime.NoStorageException; +import org.zalando.nakadi.exceptions.runtime.NoSuchStorageException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.StorageIsUsedException; @@ -73,11 +73,11 @@ public Storage createStorage(final Storage storage) throws DuplicatedStorageExce } public void deleteStorage(final String id) - throws NoStorageException, StorageIsUsedException, RepositoryProblemException { + throws NoSuchStorageException, StorageIsUsedException, RepositoryProblemException { try { final int rowDeleted = jdbcTemplate.update("DELETE FROM zn_data.storage WHERE st_id=?", id); if (rowDeleted == 0) { - throw new NoStorageException("Tried to remove storage that doesn't exist, id: " + id); + throw new NoSuchStorageException("Tried to remove storage that doesn't exist, id: " + id); } } catch (final DataIntegrityViolationException e) { throw new StorageIsUsedException("Can't delete storage as it is still used, id: " + id, e); diff --git a/src/main/java/org/zalando/nakadi/repository/db/SubscriptionDbRepository.java b/src/main/java/org/zalando/nakadi/repository/db/SubscriptionDbRepository.java index e93bb0c17f..ec8e7d5fdc 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/SubscriptionDbRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/SubscriptionDbRepository.java @@ -18,10 +18,9 @@ import org.springframework.stereotype.Component; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.DuplicatedSubscriptionException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; -import org.zalando.nakadi.exceptions.runtime.NoSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.util.HashGenerator; @@ -161,7 +160,7 @@ public List listSubscriptions(final Set eventTypes, final public Subscription getSubscription(final String owningApplication, final Set eventTypes, final String consumerGroup) - throws InconsistentStateException, NoSubscriptionException, RepositoryProblemException { + throws InconsistentStateException, NoSuchSubscriptionException, RepositoryProblemException { final String sql = "SELECT s_subscription_object FROM zn_data.subscription " + "WHERE s_subscription_object->>'owning_application' = ? " + @@ -174,7 +173,7 @@ public Subscription getSubscription(final String owningApplication, final Set cursorsLag(final String eventTypeName, final List timelines; try { timelines = timelineService.getAllTimelinesOrdered(eventTypeName); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { throw new RuntimeException(e); } return timelines.stream() diff --git a/src/main/java/org/zalando/nakadi/service/CursorsService.java b/src/main/java/org/zalando/nakadi/service/CursorsService.java index d64b4f443d..7c5481588e 100644 --- a/src/main/java/org/zalando/nakadi/service/CursorsService.java +++ b/src/main/java/org/zalando/nakadi/service/CursorsService.java @@ -8,14 +8,13 @@ import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Subscription; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.InvalidStreamIdException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.OperationTimeoutException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.UnableProcessException; @@ -128,7 +127,8 @@ private void validateStreamId(final List cursors, final String str } public List getSubscriptionCursors(final String subscriptionId) - throws NakadiException, ServiceTemporarilyUnavailableException { + throws InternalNakadiException, NoSuchEventTypeException, + NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { final Subscription subscription = subscriptionRepository.getSubscription(subscriptionId); final ZkSubscriptionClient zkSubscriptionClient = zkSubscriptionFactory.createClient( subscription, LogPathBuilder.build(subscriptionId, "get_cursors")); diff --git a/src/main/java/org/zalando/nakadi/service/EventPublisher.java b/src/main/java/org/zalando/nakadi/service/EventPublisher.java index 9738fe9949..6a7a87f5ae 100644 --- a/src/main/java/org/zalando/nakadi/service/EventPublisher.java +++ b/src/main/java/org/zalando/nakadi/service/EventPublisher.java @@ -16,11 +16,11 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.enrichment.Enrichment; -import org.zalando.nakadi.exceptions.CompactionException; -import org.zalando.nakadi.exceptions.EnrichmentException; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.PartitioningException; +import org.zalando.nakadi.exceptions.runtime.CompactionException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.EventPublishingException; import org.zalando.nakadi.exceptions.runtime.EventTypeTimeoutException; diff --git a/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java b/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java index cdfc900449..0cfc5f059a 100644 --- a/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java +++ b/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java @@ -1,7 +1,7 @@ package org.zalando.nakadi.service; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.UnprocessableEntityException; +import org.zalando.nakadi.exceptions.runtime.InvalidLimitException; import org.zalando.nakadi.security.Client; import javax.annotation.Nullable; @@ -198,13 +198,13 @@ public Builder withConsumingClient(final Client consumingClient) { } - public EventStreamConfig build() throws UnprocessableEntityException { + public EventStreamConfig build() throws InvalidLimitException { if (streamLimit != 0 && streamLimit < batchLimit) { - throw new UnprocessableEntityException("stream_limit can't be lower than batch_limit"); + throw new InvalidLimitException("stream_limit can't be lower than batch_limit"); } else if (streamTimeout != 0 && streamTimeout < batchTimeout) { - throw new UnprocessableEntityException("stream_timeout can't be lower than batch_flush_timeout"); + throw new InvalidLimitException("stream_timeout can't be lower than batch_flush_timeout"); } else if (batchLimit < 1) { - throw new UnprocessableEntityException("batch_limit can't be lower than 1"); + throw new InvalidLimitException("batch_limit can't be lower than 1"); } return new EventStreamConfig(cursors, batchLimit, streamLimit, batchTimeout, streamTimeout, streamKeepAliveLimit, etName, consumingClient, maxMemoryUsageBytes); diff --git a/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java b/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java index 9dee599d65..a83bfbad2c 100644 --- a/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java +++ b/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java @@ -4,8 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.repository.EventConsumer; import java.io.OutputStream; @@ -38,7 +37,7 @@ public EventStreamFactory( public EventStream createEventStream(final OutputStream outputStream, final EventConsumer eventConsumer, final EventStreamConfig config, final Meter bytesFlushedMeter) - throws NakadiException, InvalidCursorException { + throws InvalidCursorException { return new EventStream( eventConsumer, outputStream, diff --git a/src/main/java/org/zalando/nakadi/service/EventTypeService.java b/src/main/java/org/zalando/nakadi/service/EventTypeService.java index 1fba1e7585..8da0f8c2af 100644 --- a/src/main/java/org/zalando/nakadi/service/EventTypeService.java +++ b/src/main/java/org/zalando/nakadi/service/EventTypeService.java @@ -25,12 +25,6 @@ import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.enrichment.Enrichment; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.NoSuchPartitionStrategyException; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.ConflictException; import org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException; @@ -40,8 +34,12 @@ import org.zalando.nakadi.exceptions.runtime.EventTypeUnavailableException; import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; import org.zalando.nakadi.exceptions.runtime.InvalidEventTypeException; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchPartitionStrategyException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.NotFoundException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.TimelineException; @@ -61,6 +59,7 @@ import org.zalando.nakadi.util.JsonUtils; import org.zalando.nakadi.validation.SchemaEvolutionService; import org.zalando.nakadi.validation.SchemaIncompatibility; +import org.zalando.problem.Problem; import java.io.Closeable; import java.io.IOException; @@ -71,6 +70,8 @@ import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static org.zalando.nakadi.service.FeatureToggleService.Feature.DELETE_EVENT_TYPE_WITH_SUBSCRIPTIONS; @Component @@ -215,7 +216,7 @@ private void setDefaultEventTypeOptions(final EventTypeBase eventType) { } public void delete(final String eventTypeName) throws EventTypeDeletionException, AccessDeniedException, - NoEventTypeException, ConflictException, ServiceTemporarilyUnavailableException, + NoSuchEventTypeException, ConflictException, ServiceTemporarilyUnavailableException, DbWriteOperationsBlockedException { if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) { throw new DbWriteOperationsBlockedException("Cannot delete event type: write operations on DB " + @@ -229,7 +230,7 @@ public void delete(final String eventTypeName) throws EventTypeDeletionException final Optional eventTypeOpt = eventTypeRepository.findByNameO(eventTypeName); if (!eventTypeOpt.isPresent()) { - throw new NoEventTypeException("EventType \"" + eventTypeName + "\" does not exist."); + throw new NoSuchEventTypeException("EventType \"" + eventTypeName + "\" does not exist."); } eventType = eventTypeOpt.get(); @@ -249,7 +250,7 @@ public void delete(final String eventTypeName) throws EventTypeDeletionException LOG.error("Failed to wait for timeline switch", e); throw new EventTypeUnavailableException("Event type " + eventTypeName + " is currently in maintenance, please repeat request"); - } catch (final NakadiException | ServiceTemporarilyUnavailableException e) { + } catch (final InternalNakadiException | ServiceTemporarilyUnavailableException e) { LOG.error("Error deleting event type " + eventTypeName, e); throw new EventTypeDeletionException("Failed to delete event type " + eventTypeName); } finally { @@ -355,7 +356,7 @@ public void update(final String eventTypeName, LOG.error("Failed to wait for timeline switch", e); throw new ServiceTemporarilyUnavailableException( "Event type is currently in maintenance, please repeat request", e); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { LOG.error("Unable to update event type", e); throw new NakadiRuntimeException(e); } finally { @@ -375,7 +376,7 @@ public void update(final String eventTypeName, .put("compatibility_mode", eventTypeBase.getCompatibilityMode())); } - private void updateRetentionTime(final EventType original, final EventType eventType) throws NakadiException { + private void updateRetentionTime(final EventType original, final EventType eventType) { final Long newRetentionTime = eventType.getOptions().getRetentionTime(); final Long oldRetentionTime = original.getOptions().getRetentionTime(); if (oldRetentionTime == null) { @@ -399,13 +400,13 @@ private void updateRetentionTime(final EventType original, final EventType event } private void updateEventTypeInDB(final EventType eventType, final Long newRetentionTime, - final Long oldRetentionTime) throws NakadiException { - final NakadiException exception = transactionTemplate.execute(action -> { + final Long oldRetentionTime) throws InternalNakadiException { + final InternalNakadiException exception = transactionTemplate.execute(action -> { try { updateTimelinesCleanup(eventType.getName(), newRetentionTime, oldRetentionTime); eventTypeRepository.update(eventType); return null; - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { return e; } }); @@ -444,10 +445,10 @@ public Result get(final String eventTypeName) { return Result.ok(eventType); } catch (final NoSuchEventTypeException e) { LOG.debug("Could not find EventType: {}", eventTypeName); - return Result.problem(e.asProblem()); + return Result.problem(Problem.valueOf(NOT_FOUND, e.getMessage())); } catch (final InternalNakadiException e) { LOG.error("Problem loading event type " + eventTypeName, e); - return Result.problem(e.asProblem()); + return Result.problem(Problem.valueOf(INTERNAL_SERVER_ERROR, e.getMessage())); } } @@ -461,7 +462,7 @@ private Multimap deleteEventType(final String eventType } catch (TimelineException | NotFoundException e) { LOG.error("Problem deleting timeline for event type " + eventTypeName, e); throw new EventTypeDeletionException("Failed to delete timelines for event type " + eventTypeName); - } catch (NakadiException e) { + } catch (InternalNakadiException e) { LOG.error("Error deleting event type " + eventTypeName, e); throw new EventTypeDeletionException("Failed to delete event type " + eventTypeName); } diff --git a/src/main/java/org/zalando/nakadi/service/NakadiCursorComparator.java b/src/main/java/org/zalando/nakadi/service/NakadiCursorComparator.java index 8f7e94e0cd..8f5d7596f1 100644 --- a/src/main/java/org/zalando/nakadi/service/NakadiCursorComparator.java +++ b/src/main/java/org/zalando/nakadi/service/NakadiCursorComparator.java @@ -4,8 +4,8 @@ import org.springframework.stereotype.Component; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.db.EventTypeCache; import java.util.Comparator; diff --git a/src/main/java/org/zalando/nakadi/service/SchemaService.java b/src/main/java/org/zalando/nakadi/service/SchemaService.java index 9eb9e0b71c..544159e1e4 100644 --- a/src/main/java/org/zalando/nakadi/service/SchemaService.java +++ b/src/main/java/org/zalando/nakadi/service/SchemaService.java @@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.zalando.nakadi.domain.EventTypeSchema; -import org.zalando.nakadi.exceptions.NoSuchSchemaException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSchemaException; import org.zalando.nakadi.repository.db.SchemaRepository; import org.zalando.problem.Problem; @@ -57,7 +57,7 @@ public Result getSchemaVersion(final String name, final String return Result.ok(schema); } catch (final NoSuchSchemaException e) { LOG.debug("Could not find EventTypeSchema version: {} for EventType: {}", version, name); - return Result.problem(e.asProblem()); + return Result.problem(Problem.valueOf(Response.Status.NOT_FOUND, e.getMessage())); } } } diff --git a/src/main/java/org/zalando/nakadi/service/StorageService.java b/src/main/java/org/zalando/nakadi/service/StorageService.java index fd1c7eedfb..df3dd48cc7 100644 --- a/src/main/java/org/zalando/nakadi/service/StorageService.java +++ b/src/main/java/org/zalando/nakadi/service/StorageService.java @@ -16,7 +16,7 @@ import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException; import org.zalando.nakadi.exceptions.runtime.DuplicatedStorageException; -import org.zalando.nakadi.exceptions.runtime.NoStorageException; +import org.zalando.nakadi.exceptions.runtime.NoSuchStorageException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.StorageIsUsedException; import org.zalando.nakadi.repository.db.StorageDbRepository; @@ -152,7 +152,7 @@ public Result deleteStorage(final String id) throws DbWriteOperationsBlock } try { storageDbRepository.deleteStorage(id); - } catch (final NoStorageException e) { + } catch (final NoSuchStorageException e) { return Result.notFound("No storage with ID " + id); } catch (final StorageIsUsedException e) { return Result.forbidden("Storage " + id + " is in use"); diff --git a/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java b/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java index 2e48b8548b..d3e824d73b 100644 --- a/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java +++ b/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java @@ -4,9 +4,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.db.EventTypeCache; import org.zalando.nakadi.service.CursorConverter; diff --git a/src/main/java/org/zalando/nakadi/service/converter/VersionOneConverter.java b/src/main/java/org/zalando/nakadi/service/converter/VersionOneConverter.java index 880bfa4a86..df2fa4e126 100644 --- a/src/main/java/org/zalando/nakadi/service/converter/VersionOneConverter.java +++ b/src/main/java/org/zalando/nakadi/service/converter/VersionOneConverter.java @@ -3,9 +3,9 @@ import org.zalando.nakadi.domain.CursorError; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.db.EventTypeCache; import org.zalando.nakadi.service.CursorConverter; import org.zalando.nakadi.service.StaticStorageWorkerFactory; diff --git a/src/main/java/org/zalando/nakadi/service/converter/VersionZeroConverter.java b/src/main/java/org/zalando/nakadi/service/converter/VersionZeroConverter.java index 110b3ab012..453eb545c9 100644 --- a/src/main/java/org/zalando/nakadi/service/converter/VersionZeroConverter.java +++ b/src/main/java/org/zalando/nakadi/service/converter/VersionZeroConverter.java @@ -5,9 +5,9 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.TopicRepository; import org.zalando.nakadi.service.CursorConverter; diff --git a/src/main/java/org/zalando/nakadi/service/converter/VersionedConverter.java b/src/main/java/org/zalando/nakadi/service/converter/VersionedConverter.java index 30a5296d60..c64d695d7b 100644 --- a/src/main/java/org/zalando/nakadi/service/converter/VersionedConverter.java +++ b/src/main/java/org/zalando/nakadi/service/converter/VersionedConverter.java @@ -1,9 +1,9 @@ package org.zalando.nakadi.service.converter; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.service.CursorConverter; import org.zalando.nakadi.view.Cursor; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java b/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java index e78c586ff2..8b0a85266c 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java @@ -8,7 +8,7 @@ import org.zalando.nakadi.ShutdownHooks; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Subscription; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.service.AuthorizationValidator; import org.zalando.nakadi.service.BlacklistService; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionService.java b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionService.java index ab5593e092..dcae6188d8 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionService.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionService.java @@ -22,17 +22,15 @@ import org.zalando.nakadi.domain.SubscriptionBase; import org.zalando.nakadi.domain.SubscriptionEventTypeStats; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.Try; import org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException; import org.zalando.nakadi.exceptions.runtime.DuplicatedSubscriptionException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.InvalidCursorOperation; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; -import org.zalando.nakadi.exceptions.runtime.NoSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.SubscriptionUpdateConflictException; @@ -69,6 +67,8 @@ import java.util.Set; import java.util.stream.Collectors; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; + @Component public class SubscriptionService { @@ -123,7 +123,7 @@ public SubscriptionService(final SubscriptionDbRepository subscriptionRepository public Subscription createSubscription(final SubscriptionBase subscriptionBase) throws TooManyPartitionsException, RepositoryProblemException, DuplicatedSubscriptionException, - NoEventTypeException, InconsistentStateException, WrongInitialCursorsException, + NoSuchEventTypeException, InconsistentStateException, WrongInitialCursorsException, DbWriteOperationsBlockedException { if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) { throw new DbWriteOperationsBlockedException("Cannot create subscription: write operations on DB " + @@ -158,7 +158,7 @@ public Subscription updateSubscription(final String subscriptionId, final Subscr } public Subscription getExistingSubscription(final SubscriptionBase subscriptionBase) - throws InconsistentStateException, NoSubscriptionException, RepositoryProblemException { + throws InconsistentStateException, NoSuchSubscriptionException, RepositoryProblemException { return subscriptionRepository.getSubscription( subscriptionBase.getOwningApplication(), subscriptionBase.getEventTypes(), @@ -209,7 +209,7 @@ public Result getSubscription(final String subscriptionId) { return Result.ok(subscription); } catch (final NoSuchSubscriptionException e) { LOG.debug("Failed to find subscription: {}", subscriptionId); - return Result.problem(e.asProblem()); + return Result.problem(Problem.valueOf(NOT_FOUND, e.getMessage())); } catch (final ServiceTemporarilyUnavailableException e) { LOG.error("Error occurred when trying to get subscription: {}", subscriptionId, e); return Result.problem(Problem.valueOf(Response.Status.SERVICE_UNAVAILABLE, e.getMessage())); @@ -238,19 +238,20 @@ public Result deleteSubscription(final String subscriptionId) throws DbWri return Result.ok(); } catch (final NoSuchSubscriptionException e) { LOG.debug("Failed to find subscription: {}", subscriptionId, e); - return Result.problem(e.asProblem()); + return Result.problem(Problem.valueOf(NOT_FOUND, e.getMessage())); } catch (final ServiceTemporarilyUnavailableException e) { LOG.error("Error occurred when trying to delete subscription: {}", subscriptionId, e); return Result.problem(Problem.valueOf(Response.Status.SERVICE_UNAVAILABLE, e.getMessage())); } catch (final NoSuchEventTypeException | InternalNakadiException e) { LOG.error("Exception can not occur", e); - return Result.problem(e.asProblem()); + return Result.problem(Problem.valueOf(NOT_FOUND, e.getMessage())); } } public ItemsWrapper getSubscriptionStat(final String subscriptionId, final StatsMode statsMode) - throws InconsistentStateException, NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { + throws InconsistentStateException, NoSuchEventTypeException, + NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { final Subscription subscription; try { subscription = subscriptionRepository.getSubscription(subscriptionId); @@ -263,7 +264,7 @@ public ItemsWrapper getSubscriptionStat(final String private List createSubscriptionStat(final Subscription subscription, final StatsMode statsMode) - throws InconsistentStateException, ServiceTemporarilyUnavailableException { + throws InconsistentStateException, NoSuchEventTypeException, ServiceTemporarilyUnavailableException { final List eventTypes = getEventTypesForSubscription(subscription); final ZkSubscriptionClient subscriptionClient = createZkSubscriptionClient(subscription); final Optional zkSubscriptionNode = subscriptionClient.getZkSubscriptionNode(); @@ -285,7 +286,8 @@ private ZkSubscriptionClient createZkSubscriptionClient(final Subscription subsc } } - private List getEventTypesForSubscription(final Subscription subscription) { + private List getEventTypesForSubscription(final Subscription subscription) + throws NoSuchEventTypeException { return subscription.getEventTypes().stream() .map(Try.wrap(eventTypeRepository::findByName)) .map(Try::getOrThrow) diff --git a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java index fa4d8d4343..343a3e9bc2 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java @@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.zalando.nakadi.domain.Subscription; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.db.EventTypeCache; import org.zalando.nakadi.service.AuthorizationValidator; import org.zalando.nakadi.service.BlacklistService; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionTimeLagService.java b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionTimeLagService.java index d309a94ec8..5f0a9ce351 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionTimeLagService.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionTimeLagService.java @@ -8,12 +8,11 @@ import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.PartitionEndStatistics; -import org.zalando.nakadi.exceptions.ErrorGettingCursorTimeLagException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; +import org.zalando.nakadi.exceptions.runtime.ErrorGettingCursorTimeLagException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.LimitReachedException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; import org.zalando.nakadi.exceptions.runtime.TimeLagStatsTimeoutException; import org.zalando.nakadi.repository.EventConsumer; import org.zalando.nakadi.service.NakadiCursorComparator; @@ -89,8 +88,8 @@ public Map getTimeLags(final Collection> getSubscriptionEventTypesOrNone(final S } private void checkEventTypesExist(final Map> eventTypesOrNone) - throws NoEventTypeException { + throws NoSuchEventTypeException { final List missingEventTypes = eventTypesOrNone.entrySet().stream() .filter(entry -> !entry.getValue().isPresent()) .map(Map.Entry::getKey) .collect(Collectors.toList()); if (!missingEventTypes.isEmpty()) { - throw new NoEventTypeException(String.format("Failed to create subscription, event type(s) not found: '%s'", - StringUtils.join(missingEventTypes, "', '"))); + throw new NoSuchEventTypeException(String.format("Failed to create subscription, event type(s) not " + + "found: '%s'", StringUtils.join(missingEventTypes, "', '"))); } } } diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java index e7372496d7..d98d4c9899 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java @@ -2,8 +2,8 @@ import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.service.subscription.model.Partition; import org.zalando.nakadi.service.subscription.zk.ZkSubscription; import org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient; @@ -37,7 +37,7 @@ class ClosingState extends State { public void onExit() { try { freePartitions(new HashSet<>(listeners.keySet())); - } catch (final NakadiRuntimeException | MyNakadiRuntimeException1 ex) { + } catch (final NakadiRuntimeException | NakadiBaseException ex) { // In order not to stuck here one will just log this exception, without rethrowing getLog().error("Failed to transfer partitions when leaving ClosingState", ex); } finally { diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java index e2bbbbb47f..fee67591b7 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java @@ -6,10 +6,11 @@ import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.NoStreamingSlotsAvailable; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; +import org.zalando.nakadi.exceptions.runtime.ConflictException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoStreamingSlotsAvailable; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.SubscriptionPartitionConflictException; import org.zalando.nakadi.service.CursorConverter; @@ -19,7 +20,6 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.Collection; import java.util.EnumMap; @@ -37,13 +37,7 @@ public void onEnter() { try { getContext().checkAccessAuthorized(); } catch (final AccessDeniedException e) { - switchState(new CleanupState( - new NakadiException(e.explain()) { - @Override - protected Response.StatusType getStatus() { - return Response.Status.FORBIDDEN; - } - })); + switchState(new CleanupState(e)); return; } getZk().runLocked(this::initializeStream); @@ -94,12 +88,7 @@ private void initializeStream() { if (getZk().isCursorResetInProgress()) { switchState(new CleanupState( - new NakadiException("Resetting subscription cursors request is still in progress") { - @Override - protected Response.StatusType getStatus() { - return Response.Status.CONFLICT; - } - })); + new ConflictException("Resetting subscription cursors request is still in progress"))); return; } @@ -158,7 +147,7 @@ public List calculate( try { // get oldest active timeline return timelineService.getActiveTimelinesOrdered(et).get(0); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { throw new NakadiRuntimeException(e); } }) @@ -197,7 +186,7 @@ public List calculate( // get newest active timeline final List activeTimelines = timelineService.getActiveTimelinesOrdered(et); return activeTimelines.get(activeTimelines.size() - 1); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { throw new NakadiRuntimeException(e); } }) diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/StreamingState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/StreamingState.java index 8a02f203e5..24602e4c7d 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/StreamingState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/StreamingState.java @@ -9,9 +9,9 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.metrics.MetricUtils; import org.zalando.nakadi.metrics.StreamKpiData; @@ -553,7 +553,7 @@ private void reconfigureKafkaConsumer(final boolean forceSeek) { // removing all the current assignments for real consumer. try { eventConsumer.reassign(Collections.emptyList()); - } catch (final NakadiException | InvalidCursorException ex) { + } catch (final InvalidCursorException ex) { throw new NakadiRuntimeException(ex); } } @@ -577,7 +577,7 @@ private void reconfigureKafkaConsumer(final boolean forceSeek) { .collect(Collectors.toList()); eventConsumer.reassign(cursors); - } catch (NakadiException | InvalidCursorException ex) { + } catch (InvalidCursorException ex) { throw new NakadiRuntimeException(ex); } } @@ -590,7 +590,7 @@ private Map getBeforeFirstCursors(final Set T runLocked(final Callable function) { throw releaseException; } return result; - } catch (final NakadiRuntimeException | MyNakadiRuntimeException1 e) { + } catch (final NakadiRuntimeException | NakadiBaseException e) { throw e; } catch (final Exception e) { throw new NakadiRuntimeException(e); diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java index d68882c3ed..27d430889f 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java @@ -6,7 +6,7 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.zookeeper.KeeperException; import org.zalando.nakadi.domain.EventTypePartition; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.service.subscription.model.Partition; import org.zalando.nakadi.service.subscription.model.Session; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionClientFactory.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionClientFactory.java index 59abfe2065..47f005bc84 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionClientFactory.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionClientFactory.java @@ -5,8 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.zalando.nakadi.domain.Subscription; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; @Service diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionNotInitializedException.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionNotInitializedException.java index e462991ea4..8e4fdd384f 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionNotInitializedException.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/SubscriptionNotInitializedException.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.service.subscription.zk; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; -public class SubscriptionNotInitializedException extends MyNakadiRuntimeException1 { +public class SubscriptionNotInitializedException extends NakadiBaseException { public SubscriptionNotInitializedException(final String subscriptionId) { super("Subscription " + subscriptionId + " is not initialized"); diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscription.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscription.java index 6fdd761592..9dff6183cb 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscription.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscription.java @@ -1,6 +1,6 @@ package org.zalando.nakadi.service.subscription.zk; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import java.io.Closeable; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java index 64bdcca3e2..13dfc3f223 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.codec.binary.Hex; import org.zalando.nakadi.domain.EventTypePartition; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiBaseException; import org.zalando.nakadi.exceptions.runtime.OperationTimeoutException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.ZookeeperException; @@ -214,7 +214,7 @@ public Topology withUpdatedPartitions(final String newHash, final Partition[] pa } } if (selectedIdx < 0) { - throw new MyNakadiRuntimeException1( + throw new NakadiBaseException( "Failed to find partition " + newValue.getKey() + " in " + this); } resultPartitions[selectedIdx] = newValue; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionImpl.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionImpl.java index 529919eadb..1d0dd05f83 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionImpl.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionImpl.java @@ -5,7 +5,7 @@ import org.apache.curator.framework.api.GetDataBuilder; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import java.util.List; import java.util.function.Function; diff --git a/src/main/java/org/zalando/nakadi/service/timeline/TimelineService.java b/src/main/java/org/zalando/nakadi/service/timeline/TimelineService.java index 4a3cbfb8b4..d9253084be 100644 --- a/src/main/java/org/zalando/nakadi/service/timeline/TimelineService.java +++ b/src/main/java/org/zalando/nakadi/service/timeline/TimelineService.java @@ -20,15 +20,14 @@ import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.ConflictException; import org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException; import org.zalando.nakadi.exceptions.runtime.DuplicatedTimelineException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.NotFoundException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; @@ -225,7 +224,7 @@ public Timeline getActiveTimeline(final String eventTypeName) throws TimelineExc } throw new TimelineException(String.format("No timelines for event type %s", eventTypeName)); - } catch (final NakadiException e) { + } catch (final InternalNakadiException e) { LOG.error("Failed to get timeline for event type {}", eventTypeName, e); throw new TimelineException("Failed to get timeline", e); } @@ -251,7 +250,7 @@ public TopicRepository getTopicRepository(final Timeline timeline) } public EventConsumer createEventConsumer(@Nullable final String clientId, final List positions) - throws NakadiException, InvalidCursorException { + throws InvalidCursorException { final MultiTimelineEventConsumer result = new MultiTimelineEventConsumer( clientId, this, timelineSync, new NakadiCursorComparator(eventTypeCache)); result.reassign(positions); diff --git a/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java b/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java index fed583415c..2511eab4f6 100644 --- a/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java +++ b/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java @@ -2,7 +2,7 @@ import org.json.JSONException; import org.json.JSONObject; -import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; +import org.zalando.nakadi.exceptions.runtime.InvalidPartitionKeyFieldsException; /* One could use JsonPath Lib instead: https://github.com/jayway/JsonPath diff --git a/src/test/java/org/zalando/nakadi/controller/CursorsControllerTest.java b/src/test/java/org/zalando/nakadi/controller/CursorsControllerTest.java index b489d245e9..810f287dd3 100644 --- a/src/test/java/org/zalando/nakadi/controller/CursorsControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/CursorsControllerTest.java @@ -12,9 +12,9 @@ import org.zalando.nakadi.domain.ItemsWrapper; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.EventTypeRepository; import org.zalando.nakadi.repository.db.SubscriptionDbRepository; diff --git a/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java b/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java index a46d4142f4..65749fce4d 100644 --- a/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java @@ -16,8 +16,8 @@ import org.zalando.nakadi.domain.EventPublishResult; import org.zalando.nakadi.domain.EventPublishingStatus; import org.zalando.nakadi.domain.EventPublishingStep; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.EventTypeTimeoutException; import org.zalando.nakadi.metrics.EventTypeMetricRegistry; import org.zalando.nakadi.metrics.EventTypeMetrics; diff --git a/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java b/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java index 58eed109ee..7166c4f9ef 100644 --- a/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java @@ -20,10 +20,9 @@ import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.plugin.api.authz.AuthorizationService; import org.zalando.nakadi.repository.EventConsumer; @@ -121,7 +120,7 @@ public class EventStreamControllerTest { private AuthorizationService authorizationService; @Before - public void setup() throws NakadiException, UnknownHostException, InvalidCursorException { + public void setup() throws UnknownHostException, InvalidCursorException { EVENT_TYPE.setName(TEST_EVENT_TYPE_NAME); timeline = buildTimelineWithTopic(TEST_TOPIC); @@ -229,7 +228,7 @@ public void whenNoParamsThenDefaultsAreUsed() throws Exception { } @Test - public void whenTopicNotExistsThenTopicNotFound() throws IOException, NakadiException { + public void whenTopicNotExistsThenTopicNotFound() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenThrow(NoSuchEventTypeException.class); final StreamingResponseBody responseBody = createStreamingResponseBody(); @@ -239,7 +238,7 @@ public void whenTopicNotExistsThenTopicNotFound() throws IOException, NakadiExce } @Test - public void whenStreamLimitLowerThanBatchLimitThenUnprocessableEntity() throws NakadiException, IOException { + public void whenStreamLimitLowerThanBatchLimitThenUnprocessableEntity() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); final StreamingResponseBody responseBody = createStreamingResponseBody(20, 10, 0, 0, 0, null); @@ -250,7 +249,7 @@ public void whenStreamLimitLowerThanBatchLimitThenUnprocessableEntity() throws N } @Test - public void whenStreamTimeoutLowerThanBatchTimeoutThenUnprocessableEntity() throws NakadiException, IOException { + public void whenStreamTimeoutLowerThanBatchTimeoutThenUnprocessableEntity() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 20, 10, 0, null); @@ -261,7 +260,7 @@ public void whenStreamTimeoutLowerThanBatchTimeoutThenUnprocessableEntity() thro } @Test - public void whenBatchLimitLowerThan1ThenUnprocessableEntity() throws NakadiException, IOException { + public void whenBatchLimitLowerThan1ThenUnprocessableEntity() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, null); @@ -271,7 +270,7 @@ public void whenBatchLimitLowerThan1ThenUnprocessableEntity() throws NakadiExcep } @Test - public void whenWrongCursorsFormatThenBadRequest() throws NakadiException, IOException { + public void whenWrongCursorsFormatThenBadRequest() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, @@ -297,7 +296,7 @@ public void whenInvalidCursorsThenPreconditionFailed() throws Exception { } @Test - public void whenNoCursorsThenLatestOffsetsAreUsed() throws NakadiException, IOException, InvalidCursorException { + public void whenNoCursorsThenLatestOffsetsAreUsed() throws IOException, InvalidCursorException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); final List tps2 = ImmutableList.of( new KafkaPartitionStatistics(timeline, 0, 0, 87), @@ -370,7 +369,7 @@ public void whenNormalCaseThenParametersArePassedToConfigAndStreamStarted() thro } @Test - public void whenNakadiExceptionIsThrownThenServiceUnavailable() throws NakadiException, IOException { + public void whenNakadiExceptionIsThrownThenServiceUnavailable() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)) .thenThrow(ServiceTemporarilyUnavailableException.class); @@ -381,7 +380,7 @@ public void whenNakadiExceptionIsThrownThenServiceUnavailable() throws NakadiExc } @Test - public void whenExceptionIsThrownThenInternalServerError() throws NakadiException, IOException { + public void whenExceptionIsThrownThenInternalServerError() throws IOException { when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenThrow(NullPointerException.class); final StreamingResponseBody responseBody = createStreamingResponseBody(); @@ -505,7 +504,7 @@ private ArgumentCaptor getStatusCaptor() { return statusCaptor; } - private void prepareScopeRead() throws NakadiException, InvalidCursorException { + private void prepareScopeRead() throws InvalidCursorException { final EventConsumer.LowLevelConsumer eventConsumerMock = mock(EventConsumer.LowLevelConsumer.class); when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); when(topicRepositoryMock.createEventConsumer( diff --git a/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java b/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java index 33c08540c3..8b669eb103 100644 --- a/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java @@ -25,9 +25,8 @@ import org.zalando.nakadi.domain.ResourceAuthorizationAttribute; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.UnprocessableEntityException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; import org.zalando.nakadi.exceptions.runtime.InvalidEventTypeException; import org.zalando.nakadi.exceptions.runtime.TopicConfigException; @@ -681,19 +680,6 @@ public void whenPUTNotExistingEventTypeThen404() throws Exception { .andExpect(content().string(matchesProblem(expectedProblem))); } - @Test - public void whenPUTRepoNakadiExceptionThen422() throws Exception { - final EventType eventType = buildDefaultEventType(); - - final Problem expectedProblem = Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY); - - doThrow(UnprocessableEntityException.class).when(eventTypeRepository).findByName(eventType.getName()); - - putEventType(eventType, eventType.getName()).andExpect(status().isUnprocessableEntity()) - .andExpect(content().contentType("application/problem+json")) - .andExpect(content().string(matchesProblem(expectedProblem))); - } - @Test public void canExposeASingleEventType() throws Exception { final EventType expectedEventType = buildDefaultEventType(); diff --git a/src/test/java/org/zalando/nakadi/controller/PartitionsControllerTest.java b/src/test/java/org/zalando/nakadi/controller/PartitionsControllerTest.java index bde6e42a15..f7edc3ca70 100644 --- a/src/test/java/org/zalando/nakadi/controller/PartitionsControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/PartitionsControllerTest.java @@ -14,8 +14,8 @@ import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.EventTypeRepository; import org.zalando.nakadi.repository.TopicRepository; diff --git a/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java b/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java index 14a6ee80a9..2e94ce20f5 100644 --- a/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java @@ -16,13 +16,13 @@ import org.springframework.web.method.support.ModelAndViewContainer; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; -import org.zalando.nakadi.exceptions.runtime.NoSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.TooManyPartitionsException; import org.zalando.nakadi.plugin.api.ApplicationService; import org.zalando.nakadi.security.NakadiClient; -import org.zalando.nakadi.service.subscription.SubscriptionService; import org.zalando.nakadi.service.FeatureToggleService; +import org.zalando.nakadi.service.subscription.SubscriptionService; import org.zalando.nakadi.utils.TestUtils; import org.zalando.problem.Problem; @@ -74,7 +74,7 @@ public PostSubscriptionControllerTest() throws Exception { @Test public void whenSubscriptionCreationIsDisabledThenCreationFails() throws Exception { final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase(); - when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null)); + when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSuchSubscriptionException("", null)); when(featureToggleService.isFeatureEnabled(DISABLE_SUBSCRIPTION_CREATION)).thenReturn(true); postSubscription(subscriptionBase).andExpect(status().isServiceUnavailable()); @@ -103,7 +103,7 @@ public void whenPostValidSubscriptionThenOk() throws Exception { final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase(); final Subscription subscription = new Subscription("123", new DateTime(DateTimeZone.UTC), subscriptionBase); - when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null)); + when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSuchSubscriptionException("", null)); when(subscriptionService.createSubscription(any())).thenReturn(subscription); postSubscription(subscriptionBase) @@ -152,7 +152,7 @@ public void whenEventTypesIsEmptyThenUnprocessableEntity() throws Exception { @Test public void whenMoreThanAllowedEventTypeThenUnprocessableEntity() throws Exception { - when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null)); + when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSuchSubscriptionException("", null)); when(subscriptionService.createSubscription(any())).thenThrow(new TooManyPartitionsException("msg")); final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase(); @@ -178,8 +178,8 @@ public void whenWrongStartFromThenBadRequest() throws Exception { @Test public void whenEventTypeDoesNotExistThenUnprocessableEntity() throws Exception { final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase(); - when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null)); - when(subscriptionService.createSubscription(any())).thenThrow(new NoEventTypeException("msg")); + when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSuchSubscriptionException("", null)); + when(subscriptionService.createSubscription(any())).thenThrow(new NoSuchEventTypeException("msg")); final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "msg"); checkForProblem(postSubscription(subscriptionBase), expectedProblem); @@ -192,7 +192,7 @@ public void whenSubscriptionExistsThenReturnIt() throws Exception { subscriptionBase); when(subscriptionService.getExistingSubscription(any())).thenReturn(existingSubscription); - when(subscriptionService.createSubscription(any())).thenThrow(new NoEventTypeException("msg")); + when(subscriptionService.createSubscription(any())).thenThrow(new NoSuchEventTypeException("msg")); postSubscription(subscriptionBase) .andExpect(status().isOk()) diff --git a/src/test/java/org/zalando/nakadi/controller/SubscriptionControllerTest.java b/src/test/java/org/zalando/nakadi/controller/SubscriptionControllerTest.java index 5ce11c6ca1..df95d26a89 100644 --- a/src/test/java/org/zalando/nakadi/controller/SubscriptionControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/SubscriptionControllerTest.java @@ -22,8 +22,8 @@ import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionEventTypeStats; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.plugin.api.ApplicationService; import org.zalando.nakadi.repository.EventTypeRepository; diff --git a/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java b/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java index 5d1057dc60..e08eeaef20 100644 --- a/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java +++ b/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableMap; import org.junit.Test; -import org.zalando.nakadi.exceptions.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java b/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java index add6dadf41..a4973962a6 100644 --- a/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java +++ b/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import org.zalando.nakadi.domain.BatchItem; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; import org.zalando.nakadi.util.FlowIdUtils; import org.zalando.nakadi.utils.TestUtils; diff --git a/src/test/java/org/zalando/nakadi/partitioning/PartitionResolverTest.java b/src/test/java/org/zalando/nakadi/partitioning/PartitionResolverTest.java index 0ff78a612d..ded230526f 100644 --- a/src/test/java/org/zalando/nakadi/partitioning/PartitionResolverTest.java +++ b/src/test/java/org/zalando/nakadi/partitioning/PartitionResolverTest.java @@ -7,10 +7,9 @@ import org.mockito.Mockito; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NoSuchPartitionStrategyException; -import org.zalando.nakadi.exceptions.PartitioningException; import org.zalando.nakadi.exceptions.runtime.InvalidEventTypeException; +import org.zalando.nakadi.exceptions.runtime.NoSuchPartitionStrategyException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import org.zalando.nakadi.repository.TopicRepository; import org.zalando.nakadi.service.timeline.TimelineService; @@ -32,7 +31,7 @@ public class PartitionResolverTest { private TimelineService timelineService; @Before - public void before() throws NakadiException { + public void before() { final TopicRepository topicRepository = Mockito.mock(TopicRepository.class); when(topicRepository.listPartitionNames(any(String.class))).thenReturn(ImmutableList.of("0")); timelineService = Mockito.mock(TimelineService.class); @@ -42,7 +41,7 @@ public void before() throws NakadiException { } @Test - public void whenResolvePartitionWithKnownStrategyThenOk() throws NakadiException { + public void whenResolvePartitionWithKnownStrategyThenOk() { final EventType eventType = new EventType(); eventType.setPartitionStrategy(RANDOM_STRATEGY); @@ -57,7 +56,7 @@ public void whenResolvePartitionWithKnownStrategyThenOk() throws NakadiException } @Test(expected = PartitioningException.class) - public void whenResolvePartitionWithUnknownStrategyThenPartitioningException() throws NakadiException { + public void whenResolvePartitionWithUnknownStrategyThenPartitioningException() { final EventType eventType = new EventType(); eventType.setPartitionStrategy("blah_strategy"); diff --git a/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java b/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java index 43e917fb89..7a80b01699 100644 --- a/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java +++ b/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java @@ -3,7 +3,7 @@ import com.google.common.collect.ImmutableList; import org.json.JSONObject; import org.junit.Test; -import org.zalando.nakadi.exceptions.PartitioningException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import java.util.List; diff --git a/src/test/java/org/zalando/nakadi/repository/TopicRepositoryHolderTest.java b/src/test/java/org/zalando/nakadi/repository/TopicRepositoryHolderTest.java index becec77404..5f3ac8039d 100644 --- a/src/test/java/org/zalando/nakadi/repository/TopicRepositoryHolderTest.java +++ b/src/test/java/org/zalando/nakadi/repository/TopicRepositoryHolderTest.java @@ -5,7 +5,7 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; import org.zalando.nakadi.exceptions.runtime.TopicRepositoryException; import java.util.List; diff --git a/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java b/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java index e933a6f510..661030e5f2 100644 --- a/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java +++ b/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java @@ -3,7 +3,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; import org.zalando.nakadi.repository.EventTypeRepository; import static org.mockito.Mockito.mock; diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaCursorTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaCursorTest.java index 2b653ba9dc..cfabf2ebd7 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaCursorTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaCursorTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import org.zalando.nakadi.domain.CursorError; import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.utils.TestUtils; public class KafkaCursorTest { diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java index 205ce97def..d87efec091 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java @@ -23,7 +23,7 @@ import org.zalando.nakadi.domain.PartitionEndStatistics; import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.EventPublishingException; import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; import org.zalando.nakadi.repository.zookeeper.ZookeeperSettings; diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java index 4e87c05de2..aa300d797b 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java @@ -152,13 +152,13 @@ public void whenReadEventsThenGetRightEvents() { @Test @SuppressWarnings("unchecked") - public void whenReadEventsThenNakadiException() { + public void whenReadEventsThenNakadiRuntimeBaseException() { // ARRANGE // final ImmutableList exceptions = ImmutableList.of(new NoOffsetForPartitionException( new TopicPartition("", 0)), new KafkaException()); - int numberOfNakadiExceptions = 0; + int numberOfNakadiRuntimeBaseExceptions = 0; for (final Exception exception : exceptions) { final KafkaConsumer kafkaConsumerMock = mock(KafkaConsumer.class); when(kafkaConsumerMock.poll(POLL_TIMEOUT)).thenThrow(exception); @@ -173,11 +173,12 @@ public void whenReadEventsThenNakadiException() { // ASSERT // fail("An Exception was expected to be be thrown"); } catch (final Exception e) { - numberOfNakadiExceptions++; + numberOfNakadiRuntimeBaseExceptions++; } } - assertThat("We should get a NakadiException for every call", numberOfNakadiExceptions, + assertThat("We should get a NakadiBaseException for every call", + numberOfNakadiRuntimeBaseExceptions, equalTo(exceptions.size())); } diff --git a/src/test/java/org/zalando/nakadi/service/EventPublisherTest.java b/src/test/java/org/zalando/nakadi/service/EventPublisherTest.java index f0fd92b644..b3703584ad 100644 --- a/src/test/java/org/zalando/nakadi/service/EventPublisherTest.java +++ b/src/test/java/org/zalando/nakadi/service/EventPublisherTest.java @@ -15,8 +15,8 @@ import org.zalando.nakadi.domain.EventTypeBase; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.enrichment.Enrichment; -import org.zalando.nakadi.exceptions.EnrichmentException; -import org.zalando.nakadi.exceptions.PartitioningException; +import org.zalando.nakadi.exceptions.runtime.EnrichmentException; +import org.zalando.nakadi.exceptions.runtime.PartitioningException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.EventPublishingException; import org.zalando.nakadi.exceptions.runtime.EventTypeTimeoutException; diff --git a/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java b/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java index 27fabd59f3..972ee89d59 100644 --- a/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java +++ b/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java @@ -1,7 +1,7 @@ package org.zalando.nakadi.service; import org.junit.Test; -import org.zalando.nakadi.exceptions.UnprocessableEntityException; +import org.zalando.nakadi.exceptions.runtime.InvalidLimitException; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThanOrEqualTo; @@ -12,7 +12,7 @@ public class EventStreamConfigBuilderTest { @Test - public void batchLimitZeroValueTest() throws UnprocessableEntityException { + public void batchLimitZeroValueTest() throws InvalidLimitException { final EventStreamConfig config = EventStreamConfig .builder() .withBatchLimit(1) @@ -23,7 +23,7 @@ public void batchLimitZeroValueTest() throws UnprocessableEntityException { } @Test - public void batchLimitDefaultValueTest() throws UnprocessableEntityException { + public void batchLimitDefaultValueTest() throws InvalidLimitException { final EventStreamConfig config = EventStreamConfig .builder() .withBatchLimit(1) @@ -33,7 +33,7 @@ public void batchLimitDefaultValueTest() throws UnprocessableEntityException { } @Test - public void batchLimitSpecifiedValueTest() throws UnprocessableEntityException { + public void batchLimitSpecifiedValueTest() throws InvalidLimitException { final EventStreamConfig config = EventStreamConfig .builder() .withBatchLimit(1) @@ -43,8 +43,8 @@ public void batchLimitSpecifiedValueTest() throws UnprocessableEntityException { assertThat(config.getBatchTimeout(), is(29)); } - @Test(expected = UnprocessableEntityException.class) - public void streamLimitLessThenBatchLimit() throws UnprocessableEntityException { + @Test(expected = InvalidLimitException.class) + public void streamLimitLessThenBatchLimit() throws InvalidLimitException { EventStreamConfig .builder() .withBatchLimit(10) @@ -52,8 +52,8 @@ public void streamLimitLessThenBatchLimit() throws UnprocessableEntityException .build(); } - @Test(expected = UnprocessableEntityException.class) - public void streamTimeoutLessThenBatchTimeout() throws UnprocessableEntityException { + @Test(expected = InvalidLimitException.class) + public void streamTimeoutLessThenBatchTimeout() throws InvalidLimitException { EventStreamConfig .builder() .withBatchTimeout(10) @@ -62,7 +62,7 @@ public void streamTimeoutLessThenBatchTimeout() throws UnprocessableEntityExcept } @Test - public void streamTimeoutHigherThanMax() throws UnprocessableEntityException { + public void streamTimeoutHigherThanMax() throws InvalidLimitException { final EventStreamConfig config = EventStreamConfig .builder() .withStreamTimeout(MAX_STREAM_TIMEOUT + 100) @@ -72,7 +72,7 @@ public void streamTimeoutHigherThanMax() throws UnprocessableEntityException { } @Test - public void unlimitedStreamTimeout() throws UnprocessableEntityException { + public void unlimitedStreamTimeout() throws InvalidLimitException { final EventStreamConfig config = EventStreamConfig .builder() .withStreamTimeout(0) diff --git a/src/test/java/org/zalando/nakadi/service/EventStreamTest.java b/src/test/java/org/zalando/nakadi/service/EventStreamTest.java index d269c5fe3e..5fa6f654c3 100644 --- a/src/test/java/org/zalando/nakadi/service/EventStreamTest.java +++ b/src/test/java/org/zalando/nakadi/service/EventStreamTest.java @@ -13,7 +13,6 @@ import org.zalando.nakadi.domain.ConsumedEvent; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.NakadiException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.repository.db.EventTypeCache; import org.zalando.nakadi.repository.kafka.KafkaCursor; @@ -82,7 +81,7 @@ public static void setupMocks() { } @Test(timeout = 15000) - public void whenIOExceptionThenStreamIsClosed() throws NakadiException, InterruptedException, IOException { + public void whenIOExceptionThenStreamIsClosed() throws InterruptedException, IOException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "0"))) @@ -111,7 +110,7 @@ public void whenIOExceptionThenStreamIsClosed() throws NakadiException, Interrup } @Test(timeout = 10000) - public void whenCrutchWorkedThenStreamIsClosed() throws NakadiException, InterruptedException, IOException { + public void whenCrutchWorkedThenStreamIsClosed() throws InterruptedException, IOException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "0"))) @@ -139,7 +138,7 @@ public void whenCrutchWorkedThenStreamIsClosed() throws NakadiException, Interru } @Test(timeout = 10000) - public void whenAuthorizationChangedStreamClosed() throws NakadiException, InterruptedException, IOException { + public void whenAuthorizationChangedStreamClosed() throws InterruptedException, IOException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "0"))) @@ -181,7 +180,7 @@ public void whenAuthorizationChangedStreamClosed() throws NakadiException, Inter } @Test(timeout = 5000) - public void whenStreamTimeoutIsSetThenStreamIsClosed() throws NakadiException, IOException, InterruptedException { + public void whenStreamTimeoutIsSetThenStreamIsClosed() throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() .withBatchLimit(1) @@ -199,7 +198,7 @@ public void whenStreamTimeoutIsSetThenStreamIsClosed() throws NakadiException, I } @Test(timeout = 3000) - public void whenStreamLimitIsSetThenStreamIsClosed() throws NakadiException, IOException, InterruptedException { + public void whenStreamLimitIsSetThenStreamIsClosed() throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "0"))) @@ -216,7 +215,7 @@ public void whenStreamLimitIsSetThenStreamIsClosed() throws NakadiException, IOE } @Test(timeout = 5000) - public void whenKeepAliveLimitIsSetThenStreamIsClosed() throws NakadiException, IOException, InterruptedException { + public void whenKeepAliveLimitIsSetThenStreamIsClosed() throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "0"))) @@ -234,7 +233,7 @@ public void whenKeepAliveLimitIsSetThenStreamIsClosed() throws NakadiException, } @Test(timeout = 15000) - public void whenNoEventsToReadThenKeepAliveIsSent() throws NakadiException, IOException, InterruptedException { + public void whenNoEventsToReadThenKeepAliveIsSent() throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "000000000000000000"))) @@ -261,7 +260,7 @@ public void whenNoEventsToReadThenKeepAliveIsSent() throws NakadiException, IOEx } @Test(timeout = 10000) - public void whenBatchSizeIsSetThenGetEventsInBatches() throws NakadiException, IOException, InterruptedException { + public void whenBatchSizeIsSetThenGetEventsInBatches() throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", String.format("%18d", 0)))) @@ -291,7 +290,7 @@ public void whenBatchSizeIsSetThenGetEventsInBatches() throws NakadiException, I } @Test(timeout = 10000) - public void whenReadingEventsTheOrderIsCorrect() throws NakadiException, IOException, InterruptedException { + public void whenReadingEventsTheOrderIsCorrect() throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() .withCursors(ImmutableList.of(NakadiCursor.of(TIMELINE, "0", "0"))) @@ -332,7 +331,7 @@ public void whenReadingEventsTheOrderIsCorrect() throws NakadiException, IOExcep @Test(timeout = 10000) public void whenReadFromMultiplePartitionsThenGroupedInBatchesAccordingToPartition() - throws NakadiException, IOException, InterruptedException { + throws IOException, InterruptedException { final EventStreamConfig config = EventStreamConfig .builder() @@ -373,13 +372,13 @@ public void whenReadFromMultiplePartitionsThenGroupedInBatchesAccordingToPartiti Optional.of(nCopies(2, new String(DUMMY)))))); } - private static NakadiKafkaConsumer emptyConsumer() throws NakadiException { + private static NakadiKafkaConsumer emptyConsumer() { final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class); when(nakadiKafkaConsumer.readEvents()).thenReturn(Collections.emptyList()); return nakadiKafkaConsumer; } - private static NakadiKafkaConsumer endlessDummyConsumerForPartition(final String partition) throws NakadiException { + private static NakadiKafkaConsumer endlessDummyConsumerForPartition(final String partition) { final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class); when(nakadiKafkaConsumer.readEvents()) .thenReturn(Collections.singletonList( @@ -387,8 +386,7 @@ private static NakadiKafkaConsumer endlessDummyConsumerForPartition(final String return nakadiKafkaConsumer; } - private static NakadiKafkaConsumer nCountDummyConsumerForPartition(final int eventNum, final String partition) - throws NakadiException { + private static NakadiKafkaConsumer nCountDummyConsumerForPartition(final int eventNum, final String partition) { final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class); final AtomicInteger eventsToCreate = new AtomicInteger(eventNum); when(nakadiKafkaConsumer.readEvents()).thenAnswer(invocation -> { @@ -403,8 +401,7 @@ private static NakadiKafkaConsumer nCountDummyConsumerForPartition(final int eve return nakadiKafkaConsumer; } - private static NakadiKafkaConsumer predefinedConsumer(final List events) - throws NakadiException { + private static NakadiKafkaConsumer predefinedConsumer(final List events) { final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class); final AtomicBoolean sent = new AtomicBoolean(false); when(nakadiKafkaConsumer.readEvents()).thenAnswer(invocation -> { @@ -418,7 +415,7 @@ private static NakadiKafkaConsumer predefinedConsumer(final List return nakadiKafkaConsumer; } - private static NakadiKafkaConsumer endlessDummyConsumer() throws NakadiException { + private static NakadiKafkaConsumer endlessDummyConsumer() { return endlessDummyConsumerForPartition("0"); } diff --git a/src/test/java/org/zalando/nakadi/service/EventTypeServiceTest.java b/src/test/java/org/zalando/nakadi/service/EventTypeServiceTest.java index 28bc58bd9e..e572a5b5f1 100644 --- a/src/test/java/org/zalando/nakadi/service/EventTypeServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/EventTypeServiceTest.java @@ -13,7 +13,7 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.enrichment.Enrichment; -import org.zalando.nakadi.exceptions.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; import org.zalando.nakadi.exceptions.runtime.ConflictException; import org.zalando.nakadi.exceptions.runtime.EventTypeDeletionException; import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; diff --git a/src/test/java/org/zalando/nakadi/service/NakadiCursorComparatorTest.java b/src/test/java/org/zalando/nakadi/service/NakadiCursorComparatorTest.java index f7f6de0d83..f2f10c87b2 100644 --- a/src/test/java/org/zalando/nakadi/service/NakadiCursorComparatorTest.java +++ b/src/test/java/org/zalando/nakadi/service/NakadiCursorComparatorTest.java @@ -6,8 +6,8 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.repository.db.EventTypeCache; import org.zalando.nakadi.repository.kafka.KafkaCursor; diff --git a/src/test/java/org/zalando/nakadi/service/SchemaServiceTest.java b/src/test/java/org/zalando/nakadi/service/SchemaServiceTest.java index 685d04e8d4..5d7fd724fb 100644 --- a/src/test/java/org/zalando/nakadi/service/SchemaServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/SchemaServiceTest.java @@ -8,7 +8,7 @@ import org.zalando.nakadi.domain.EventTypeSchema; import org.zalando.nakadi.domain.PaginationWrapper; import org.zalando.nakadi.domain.Version; -import org.zalando.nakadi.exceptions.NoSuchSchemaException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSchemaException; import org.zalando.nakadi.repository.db.SchemaRepository; import javax.ws.rs.core.Response; diff --git a/src/test/java/org/zalando/nakadi/service/StorageServiceTest.java b/src/test/java/org/zalando/nakadi/service/StorageServiceTest.java index 8351ca69e0..0e10138dfc 100644 --- a/src/test/java/org/zalando/nakadi/service/StorageServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/StorageServiceTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import org.zalando.nakadi.domain.DefaultStorage; import org.zalando.nakadi.domain.Storage; -import org.zalando.nakadi.exceptions.runtime.NoStorageException; +import org.zalando.nakadi.exceptions.runtime.NoSuchStorageException; import org.zalando.nakadi.exceptions.runtime.StorageIsUsedException; import org.zalando.nakadi.repository.db.StorageDbRepository; import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; @@ -64,7 +64,7 @@ public void testDeleteStorageInUse() throws Exception { @Test public void testDeleteNonExistingStorage() throws Exception { - doThrow(new NoStorageException("")).when(storageDbRepository).deleteStorage("s"); + doThrow(new NoSuchStorageException("")).when(storageDbRepository).deleteStorage("s"); final Result result = storageService.deleteStorage("s"); diff --git a/src/test/java/org/zalando/nakadi/service/SubscriptionServiceTest.java b/src/test/java/org/zalando/nakadi/service/SubscriptionServiceTest.java index 0ddd75ac8e..70bebfa13e 100644 --- a/src/test/java/org/zalando/nakadi/service/SubscriptionServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/SubscriptionServiceTest.java @@ -6,7 +6,7 @@ import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; import org.zalando.nakadi.domain.SubscriptionResource; -import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; +import org.zalando.nakadi.exceptions.runtime.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.runtime.AccessDeniedException; import org.zalando.nakadi.exceptions.runtime.UnableProcessException; import org.zalando.nakadi.plugin.api.authz.AuthorizationService; diff --git a/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java b/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java index 6c444166c9..df885b643d 100644 --- a/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java @@ -9,10 +9,10 @@ import org.zalando.nakadi.domain.PartitionEndStatistics; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.ErrorGettingCursorTimeLagException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; +import org.zalando.nakadi.exceptions.runtime.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.ErrorGettingCursorTimeLagException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.repository.EventConsumer; import org.zalando.nakadi.service.subscription.SubscriptionTimeLagService; import org.zalando.nakadi.service.timeline.TimelineService; @@ -45,7 +45,7 @@ public void setUp() throws Exception { } @Test - public void testTimeLagsForTailAndNotTailPositions() throws NakadiException, InvalidCursorException { + public void testTimeLagsForTailAndNotTailPositions() throws InvalidCursorException { final EventConsumer eventConsumer = mock(EventConsumer.class); final Timeline timeline = mock(Timeline.class); @@ -81,9 +81,9 @@ public void testTimeLagsForTailAndNotTailPositions() throws NakadiException, Inv @Test(expected = InconsistentStateException.class) @SuppressWarnings("unchecked") - public void whenNakadiExceptionThenInconsistentStateExceptionIsThrown() - throws NakadiException, InvalidCursorException { - when(timelineService.createEventConsumer(any(), any())).thenThrow(NakadiException.class); + public void whenNakadiRuntimeExceptionThenInconsistentStateExceptionIsThrown() + throws InvalidCursorException { + when(timelineService.createEventConsumer(any(), any())).thenThrow(NakadiRuntimeException.class); final Timeline et1Timeline = new Timeline("et1", 0, new Storage("", Storage.Type.KAFKA), "t1", null); final NakadiCursor committedCursor1 = NakadiCursor.of(et1Timeline, "p1", "o1"); @@ -94,7 +94,7 @@ public void whenNakadiExceptionThenInconsistentStateExceptionIsThrown() @Test(expected = ErrorGettingCursorTimeLagException.class) @SuppressWarnings("unchecked") public void whenInvalidCursorThenErrorGettingCursorTimeLagExceptionIsThrown() - throws NakadiException, InvalidCursorException { + throws InvalidCursorException { when(timelineService.createEventConsumer(any(), any())).thenThrow(InvalidCursorException.class); final Timeline et1Timeline = new Timeline("et1", 0, new Storage("", Storage.Type.KAFKA), "t1", null); diff --git a/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java b/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java index 7068bffa35..b02b376fe4 100644 --- a/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java @@ -10,10 +10,10 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.SubscriptionBase; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; -import org.zalando.nakadi.exceptions.runtime.NoEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.exceptions.runtime.TooManyPartitionsException; @@ -104,8 +104,8 @@ public void whenNoEventTypeThenException() throws Exception { try { subscriptionValidationService.validateSubscription(subscriptionBase); - fail("NoEventTypeException expected"); - } catch (final NoEventTypeException e) { + fail("NoSuchEventTypeException expected"); + } catch (final NoSuchEventTypeException e) { final String expectedMessage = String.format("Failed to create subscription, event type(s) not found: '%s', '%s'", ET1, ET3); assertThat(e.getMessage(), equalTo(expectedMessage)); diff --git a/src/test/java/org/zalando/nakadi/service/converter/VersionOneConverterTest.java b/src/test/java/org/zalando/nakadi/service/converter/VersionOneConverterTest.java index 85a649c4b2..f0de627811 100644 --- a/src/test/java/org/zalando/nakadi/service/converter/VersionOneConverterTest.java +++ b/src/test/java/org/zalando/nakadi/service/converter/VersionOneConverterTest.java @@ -8,7 +8,7 @@ import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.repository.db.EventTypeCache; import org.zalando.nakadi.view.Cursor; diff --git a/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java b/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java index 20fa8c66ca..4461584ec5 100644 --- a/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java +++ b/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java @@ -2,9 +2,9 @@ import org.junit.Before; import org.junit.Test; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.Cursor; diff --git a/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java b/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java index 1a1bc932d8..538bf75942 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java @@ -2,7 +2,6 @@ import com.google.common.collect.ImmutableList; import org.junit.Test; -import org.zalando.nakadi.exceptions.UnprocessableEntityException; import org.zalando.nakadi.exceptions.runtime.WrongStreamParametersException; import org.zalando.nakadi.security.Client; import org.zalando.nakadi.service.EventStreamConfig; @@ -94,7 +93,7 @@ public static StreamParameters createStreamParameters(final int batchLimitEvents final Integer batchKeepAliveIterations, final int maxUncommittedMessages, final long commitTimeoutSeconds, - final Client client) throws UnprocessableEntityException { + final Client client) throws WrongStreamParametersException { final UserStreamParameters userParams = new UserStreamParameters(batchLimitEvents, streamLimitEvents, batchTimeoutSeconds, streamTimeoutSeconds, batchKeepAliveIterations, maxUncommittedMessages, ImmutableList.of()); diff --git a/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java b/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java index c6d42ad2dc..e77027e37a 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java @@ -11,9 +11,9 @@ import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException; import org.zalando.nakadi.repository.EventConsumer; import org.zalando.nakadi.repository.TopicRepository; diff --git a/src/test/java/org/zalando/nakadi/service/timeline/TimelineServiceTest.java b/src/test/java/org/zalando/nakadi/service/timeline/TimelineServiceTest.java index 27153642cc..03b324918e 100644 --- a/src/test/java/org/zalando/nakadi/service/timeline/TimelineServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/timeline/TimelineServiceTest.java @@ -12,8 +12,8 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Storage; import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.exceptions.InternalNakadiException; -import org.zalando.nakadi.exceptions.NoSuchEventTypeException; +import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; +import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; import org.zalando.nakadi.exceptions.runtime.InconsistentStateException; import org.zalando.nakadi.exceptions.runtime.NotFoundException; import org.zalando.nakadi.exceptions.runtime.TimelineException; diff --git a/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java b/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java index 28d847ec5a..28b83ec187 100644 --- a/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java +++ b/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java @@ -2,7 +2,7 @@ import org.json.JSONObject; import org.junit.Test; -import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; +import org.zalando.nakadi.exceptions.runtime.InvalidPartitionKeyFieldsException; import org.zalando.nakadi.utils.TestUtils; import java.io.IOException;