Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #857 from zalando/INC-13145
Browse files Browse the repository at this point in the history
INC-13145 Do not log stack trace when users provide a non-existing subscription ID
  • Loading branch information
lmontrieux authored Apr 3, 2018
2 parents 2be882e + f77257e commit 34bb11f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.6.1] - 2018-04-03

### Fixed
- Do not log a complete stack trace when a user makes a request for a non-existing subscription

## [2.6.0] - 2018-03-26

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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.SubscriptionPartitionConflictException;
import org.zalando.nakadi.exceptions.runtime.WrongStreamParametersException;
Expand Down Expand Up @@ -113,7 +114,7 @@ public void onInitialized(final String sessionId) throws IOException {

@Override
public void onException(final Exception ex) {
LOG.warn("Exception occurred while streaming", ex);
LOG.warn("Exception occurred while streaming: {}", ex.getMessage());
if (!headersSent) {
headersSent = true;
try {
Expand All @@ -126,6 +127,9 @@ public void onException(final Exception ex) {
} else if (ex instanceof WrongStreamParametersException) {
writeProblemResponse(response, out, Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY,
ex.getMessage()));
} else if (ex instanceof NoSuchSubscriptionException) {
writeProblemResponse(response, out, Problem.valueOf(Response.Status.NOT_FOUND,
ex.getMessage()));
} else if (ex instanceof NakadiException) {
writeProblemResponse(response, out, ((NakadiException) ex).asProblem());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Subscription getSubscription(final String id) throws NoSuchSubscriptionEx
try {
return jdbcTemplate.queryForObject(sql, new Object[]{id}, rowMapper);
} catch (final EmptyResultDataAccessException e) {
throw new NoSuchSubscriptionException("Subscription with id \"" + id + "\" does not exist", e);
throw new NoSuchSubscriptionException("Subscription with id \"" + id + "\" does not exist");
} catch (final DataAccessException e) {
LOG.error("Database error when getting subscription", e);
throw new ServiceUnavailableException("Error occurred when running database request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.zalando.nakadi.exceptions.NakadiException;
import org.zalando.nakadi.exceptions.NoSuchSubscriptionException;
import org.zalando.nakadi.repository.db.SubscriptionDbRepository;
import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder;

Expand Down Expand Up @@ -77,6 +78,8 @@ public boolean isSubscriptionConsumptionBlocked(final String subscriptionId, fin
try {
return isSubscriptionConsumptionBlocked(
subscriptionDbRepository.getSubscription(subscriptionId).getEventTypes(), appId);
} catch (final NoSuchSubscriptionException e) {
LOG.error(e.getMessage());
} catch (final NakadiException e) {
LOG.error(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Result<Subscription> getSubscription(final String subscriptionId) {
final Subscription subscription = subscriptionRepository.getSubscription(subscriptionId);
return Result.ok(subscription);
} catch (final NoSuchSubscriptionException e) {
LOG.debug("Failed to find subscription: {}", subscriptionId, e);
LOG.debug("Failed to find subscription: {}", subscriptionId);
return Result.problem(e.asProblem());
} catch (final ServiceUnavailableException e) {
LOG.error("Error occurred when trying to get subscription: {}", subscriptionId, e);
Expand Down

0 comments on commit 34bb11f

Please sign in to comment.