From ae0871ea7777a634e1e22de42d584a24228ed7b9 Mon Sep 17 00:00:00 2001 From: Lionel Montrieux Date: Tue, 10 Apr 2018 22:05:45 +0200 Subject: [PATCH] Do not log stack trace when event type does not exist --- CHANGELOG.md | 5 +++++ .../zalando/nakadi/controller/EventPublishingController.java | 2 +- .../zalando/nakadi/repository/db/EventTypeDbRepository.java | 2 +- .../org/zalando/nakadi/service/timeline/TimelineService.java | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87b4384bdd..5609a9834d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [2.6.3] = 2018-04-10 + +### Fixed +- Do not log a complete stack trace when a user tries to publish to a non-existing event type + ## [2.6.2] - 2018-04-05 ### Changed diff --git a/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java b/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java index d5ed1d9ee4..e8e8a7fddf 100644 --- a/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java +++ b/src/main/java/org/zalando/nakadi/controller/EventPublishingController.java @@ -108,7 +108,7 @@ private ResponseEntity postEventInternal(final String eventTypeName, LOG.debug("Problem parsing event", e); return processJSONException(e, nativeWebRequest); } catch (final NoSuchEventTypeException e) { - LOG.debug("Event type not found.", e); + LOG.debug("Event type not found.", e.getMessage()); return create(e.asProblem(), nativeWebRequest); } catch (final NakadiException e) { LOG.debug("Failed to publish batch", e); 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 3a871f59be..1707a118d1 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java @@ -61,7 +61,7 @@ public EventType findByName(final String name) throws NoSuchEventTypeException { try { return jdbcTemplate.queryForObject(sql, new Object[]{name}, new EventTypeMapper()); } catch (EmptyResultDataAccessException e) { - throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist.", e); + throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist."); } } 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 017cfd167e..e67fc3c9e6 100644 --- a/src/main/java/org/zalando/nakadi/service/timeline/TimelineService.java +++ b/src/main/java/org/zalando/nakadi/service/timeline/TimelineService.java @@ -126,7 +126,7 @@ public void createTimeline(final String eventTypeName, final String storageId) } catch (final TopicCreationException | ServiceUnavailableException | InternalNakadiException e) { throw new TimelineException("Internal service error", e); } catch (final NoSuchEventTypeException e) { - throw new NotFoundException("EventType \"" + eventTypeName + "\" does not exist", e); + throw new NotFoundException("EventType \"" + eventTypeName + "\" does not exist"); } } @@ -324,7 +324,7 @@ public List getTimelines(final String eventTypeName) final EventType eventType = eventTypeCache.getEventType(eventTypeName); return timelineDbRepository.listTimelinesOrdered(eventType.getName()); } catch (final NoSuchEventTypeException e) { - throw new NotFoundException("EventType \"" + eventTypeName + "\" does not exist", e); + throw new NotFoundException("EventType \"" + eventTypeName + "\" does not exist"); } catch (final InternalNakadiException e) { throw new TimelineException("Could not get event type: " + eventTypeName, e); }