This is an automated email from the ASF dual-hosted git repository.
chanholee pushed a commit to branch branch-0.12
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/branch-0.12 by this push:
new 051eaa6242 [ZEPPELIN-6356] Fix ZeppelinClientIntegrationTest
051eaa6242 is described below
commit 051eaa62424380b07f74304f26e27bb9eb6e2879
Author: ChanHo Lee <[email protected]>
AuthorDate: Sun Oct 19 20:47:46 2025 +0900
[ZEPPELIN-6356] Fix ZeppelinClientIntegrationTest
### What is this PR for?
After #5090, we started hiding unhandled error details from clients, which
caused some tests that depended on those details to fail. The afffected cases
are note imports/creations that should fail when the target note path already
exists.
This PR introduces a `ConflictException` and updates `NotebookRestApi` to
return HTTP 409 (Conflict) when `NotebookService` throws or returns
`NotePathAlreadyExistsException`.
I chose to do this exception-to-HTTP mapping in `NotebookRestApi` because
`NotebookService` is also used outside REST contexts, and assigning HTTP status
codes belongs in the REST layer.
### What type of PR is it?
Bug Fix
### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-6356
### How should this be tested?
- Check if `zeppelin-integration-test` and other tests pass
### Screenshots (if appropriate)
<img width="1609" height="100" alt="image"
src="https://github.com/user-attachments/assets/a445f36c-0267-42df-a75e-9f9f05f94964"
/>
### Questions:
* Does the license files need to update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Closes #5097 from tbonelee/fix-client-integration-test.
Signed-off-by: ChanHo Lee <[email protected]>
(cherry picked from commit 33f35dcf3c0b0b1caf9572210ab7eeb163f4628b)
Signed-off-by: ChanHo Lee <[email protected]>
---
.../src/main/java/org/apache/zeppelin/rest/AbstractRestApi.java | 2 ++
.../apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java | 4 ++++
.../src/main/java/org/apache/zeppelin/service/NotebookService.java | 4 +++-
.../zeppelin/notebook/exception/NotePathAlreadyExistsException.java | 4 ++++
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git
a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/AbstractRestApi.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/AbstractRestApi.java
index a9bfac51d5..67b2ab2adc 100644
---
a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/AbstractRestApi.java
+++
b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/AbstractRestApi.java
@@ -55,6 +55,8 @@ public class AbstractRestApi {
super.onFailure(ex, context);
if (ex instanceof WebApplicationException) {
throw (WebApplicationException) ex;
+ } else if (ex instanceof IOException) {
+ throw (IOException) ex;
} else {
throw new IOException(ex);
}
diff --git
a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java
index e5c99cf50b..f360afdfd3 100644
---
a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java
+++
b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java
@@ -22,6 +22,8 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
+import org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException;
+import org.apache.zeppelin.utils.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +36,8 @@ public class WebApplicationExceptionMapper implements
ExceptionMapper<Throwable>
public Response toResponse(Throwable exception) {
if (exception instanceof WebApplicationException) {
return ((WebApplicationException) exception).getResponse();
+ } else if (exception instanceof NotePathAlreadyExistsException) {
+ return ExceptionUtils.jsonResponseContent(Response.Status.CONFLICT,
exception.getMessage());
} else {
LOGGER.error("Error response", exception);
// Return generic error message to prevent information disclosure
diff --git
a/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
index 3947f4f186..fbc1507f79 100644
---
a/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
+++
b/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
@@ -385,7 +385,9 @@ public class NotebookService {
callback.onSuccess(note, context);
return note.getId();
});
-
+ } catch (NotePathAlreadyExistsException e) {
+ callback.onFailure(new NotePathAlreadyExistsException("Fail to import
note: " + e.getMessage(), e), context);
+ return null;
} catch (IOException e) {
callback.onFailure(new IOException("Fail to import note: " +
e.getMessage(), e), context);
return null;
diff --git
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/exception/NotePathAlreadyExistsException.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/exception/NotePathAlreadyExistsException.java
index ee897584e2..99ba82bd8b 100644
---
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/exception/NotePathAlreadyExistsException.java
+++
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/exception/NotePathAlreadyExistsException.java
@@ -26,4 +26,8 @@ public class NotePathAlreadyExistsException extends
IOException {
super(message);
}
+ public NotePathAlreadyExistsException(final String message, final
Throwable cause) {
+ super(message, cause);
+ }
+
}