Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,4 @@ gradle-app.setting

# node
node_modules/
CLAUDE.md
51 changes: 26 additions & 25 deletions common/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
# This file is expected to be part of source control.
com.github.oowekyala.ooxml:nice-xml-messages:3.1=pmd
com.github.rholder:guava-retrying:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.spotbugs:spotbugs-annotations:4.9.8=annotationProcessor,compileClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath
com.github.spotbugs:spotbugs:4.9.8=spotbugs
com.github.spotbugs:spotbugs-annotations:4.10.2=compileClasspath,spotbugs,testCompileClasspath
com.github.spotbugs:spotbugs-annotations:4.9.8=annotationProcessor,testAnnotationProcessor
com.github.spotbugs:spotbugs:4.10.2=spotbugs
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.13.2=pmd,spotbugs
com.google.code.gson:gson:2.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.13.2=pmd
com.google.code.gson:gson:2.14.0=compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.36.0=checkstyle
com.google.errorprone:error_prone_annotations:2.41.0=pmd,spotbugs
com.google.errorprone:error_prone_annotations:2.48.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.41.0=pmd
com.google.errorprone:error_prone_annotations:2.48.0=compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
com.google.guava:failureaccess:1.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:failureaccess:1.0.3=checkstyle
com.google.guava:guava:32.1.3-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:32.0.1-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:33.4.8-jre=checkstyle
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=checkstyle,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.j2objc:j2objc-annotations:2.8=compileClasspath,testCompileClasspath
com.google.j2objc:j2objc-annotations:2.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.j2objc:j2objc-annotations:3.0.0=checkstyle
com.puppycrawl.tools:checkstyle:10.25.0=checkstyle
commons-beanutils:commons-beanutils:1.11.0=checkstyle
commons-codec:commons-codec:1.15=checkstyle
commons-collections:commons-collections:3.2.2=checkstyle
commons-io:commons-io:2.20.0=spotbugs
commons-io:commons-io:2.21.0=spotbugs
info.picocli:picocli:4.7.7=checkstyle
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
jaxen:jaxen:2.0.0=spotbugs
jaxen:jaxen:2.0.6=spotbugs
net.bytebuddy:byte-buddy-agent:1.17.7=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.17.7=testCompileClasspath,testRuntimeClasspath
net.sf.saxon:Saxon-HE:12.5=checkstyle
Expand All @@ -36,27 +37,25 @@ net.sourceforge.pmd:pmd-core:7.22.0=pmd
net.sourceforge.pmd:pmd-java:7.22.0=pmd
org.antlr:antlr4-runtime:4.13.2=checkstyle
org.antlr:antlr4-runtime:4.9.3=pmd
org.apache.bcel:bcel:6.11.0=spotbugs
org.apache.bcel:bcel:6.12.0=spotbugs
org.apache.commons:commons-lang3:3.18.0=checkstyle
org.apache.commons:commons-lang3:3.19.0=spotbugs
org.apache.commons:commons-lang3:3.20.0=compileClasspath,pmd,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-text:1.14.0=spotbugs
org.apache.commons:commons-text:1.15.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-lang3:3.20.0=compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-text:1.15.0=compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-text:1.3=checkstyle
org.apache.httpcomponents.client5:httpclient5:5.1.3=checkstyle
org.apache.httpcomponents.core5:httpcore5-h2:5.1.3=checkstyle
org.apache.httpcomponents.core5:httpcore5:5.1.3=checkstyle
org.apache.httpcomponents:httpclient:4.5.13=checkstyle
org.apache.httpcomponents:httpcore:4.4.14=checkstyle
org.apache.logging.log4j:log4j-api:2.25.3=spotbugs
org.apache.logging.log4j:log4j-core:2.25.3=spotbugs
org.apache.logging.log4j:log4j-api:2.26.0=spotbugs
org.apache.logging.log4j:log4j-core:2.26.0=spotbugs
org.apache.maven.doxia:doxia-core:1.12.0=checkstyle
org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle
org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle
org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle
org.apache.xbean:xbean-reflect:3.7=checkstyle
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.checkerframework:checker-qual:3.37.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.49.3=checkstyle
org.checkerframework:checker-qual:3.53.1=pmd
org.codehaus.groovy:groovy:3.0.24=testCompileClasspath,testRuntimeClasspath
Expand All @@ -75,25 +74,27 @@ org.jspecify:jspecify:1.0.0=checkstyle
org.junit.jupiter:junit-jupiter-api:5.14.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.14.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.14.0=testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:5.14.0=annotationProcessor,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:5.14.0=annotationProcessor,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:6.1.0=spotbugs
org.mockito:mockito-core:5.23.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm-analysis:9.9=spotbugs
org.ow2.asm:asm-analysis:9.10.1=spotbugs
org.ow2.asm:asm-commons:9.10.1=spotbugs
org.ow2.asm:asm-commons:9.8=jacocoAnt
org.ow2.asm:asm-commons:9.9=spotbugs
org.ow2.asm:asm-tree:9.10.1=spotbugs
org.ow2.asm:asm-tree:9.8=jacocoAnt
org.ow2.asm:asm-tree:9.9=spotbugs
org.ow2.asm:asm-util:9.9=spotbugs
org.ow2.asm:asm-util:9.10.1=spotbugs
org.ow2.asm:asm:9.10.1=spotbugs
org.ow2.asm:asm:9.8=jacocoAnt
org.ow2.asm:asm:9.9=spotbugs
org.ow2.asm:asm:9.9.1=pmd
org.pcollections:pcollections:4.0.2=pmd
org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath
org.reflections:reflections:0.10.2=checkstyle
org.slf4j:jul-to-slf4j:1.7.36=pmd
org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j
org.slf4j:slf4j-api:2.0.17=spotbugsSlf4j
org.slf4j:slf4j-api:2.0.18=spotbugs
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
org.spockframework:spock-bom:2.4-M6-groovy-3.0=testCompileClasspath,testRuntimeClasspath
org.spockframework:spock-core:2.4-M6-groovy-3.0=testCompileClasspath,testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ public final void setTimeout(Duration timeout) {
/**
* Called before the request starts. Sets start time. Override to add behavior. Be sure to call {@code super.start()}
*/
@SuppressFBWarnings("USO_UNSAFE_METHOD_SYNCHRONIZATION")
public synchronized void start() {
if (attemptCount < 1) {
attemptCount = 1;
Expand All @@ -579,6 +580,7 @@ public synchronized void start() {
/**
* Called before retrying request. Sets start time. Override to add behavior. Be sure to call {@code super.startRetry()}
*/
@SuppressFBWarnings("USO_UNSAFE_METHOD_SYNCHRONIZATION")
public synchronized void startRetry() {
attemptCount++;
startNano = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
package com.mx.path.core.common.accessor

import spock.lang.Specification

class AccessorExceptionsTest extends Specification {

static class ConcreteSystemException extends AccessorSystemException {
ConcreteSystemException(String message) {
super(message)
}
ConcreteSystemException(String message, Throwable cause) {
super(message, cause)
}
}

static class ConcreteUserException extends AccessorUserException {
ConcreteUserException(String message, PathResponseStatus status) {
super(message, status)
}
ConcreteUserException(String message, PathResponseStatus status, Throwable cause) {
super(message, status, cause)
}
ConcreteUserException(String message, String userMessage, PathResponseStatus status) {
super(message, userMessage, status)
}
ConcreteUserException(String message, String userMessage, PathResponseStatus status, Throwable cause) {
super(message, userMessage, status, cause)
}
}

def "AccessorSystemException sets INTERNAL_ERROR status and shouldReport=true"() {
given:
def ex = new ConcreteSystemException("system error")

expect:
ex.getMessage() == "system error"
ex.getStatus() == PathResponseStatus.INTERNAL_ERROR
ex.shouldReport()
}

def "AccessorSystemException with cause preserves cause"() {
given:
def cause = new RuntimeException("root")
def ex = new ConcreteSystemException("system error", cause)

expect:
ex.getCause().is(cause)
ex.getStatus() == PathResponseStatus.INTERNAL_ERROR
ex.shouldReport()
}

def "AccessorUserException sets status and shouldReport=false"() {
given:
def ex = new ConcreteUserException("user error", PathResponseStatus.NOT_FOUND)

expect:
ex.getMessage() == "user error"
ex.getStatus() == PathResponseStatus.NOT_FOUND
!ex.shouldReport()
}

def "AccessorUserException with cause"() {
given:
def cause = new RuntimeException("root")
def ex = new ConcreteUserException("user error", PathResponseStatus.BAD_REQUEST, cause)

expect:
ex.getCause().is(cause)
!ex.shouldReport()
}

def "AccessorUserException with userMessage"() {
given:
def ex = new ConcreteUserException("internal msg", "user msg", PathResponseStatus.UNAUTHORIZED)

expect:
ex.getMessage() == "internal msg"
ex.getUserMessage() == "user msg"
ex.getStatus() == PathResponseStatus.UNAUTHORIZED
}

def "AccessorUserException with userMessage and cause"() {
given:
def cause = new RuntimeException("root")
def ex = new ConcreteUserException("internal msg", "user msg", PathResponseStatus.UNAUTHORIZED, cause)

expect:
ex.getCause().is(cause)
ex.getUserMessage() == "user msg"
}

def "ResourceNotFoundException message constructor"() {
given:
def ex = new ResourceNotFoundException("not found")

expect:
ex.getStatus() == PathResponseStatus.NOT_FOUND
ex.getMessage() == "not found"
}

def "ResourceNotFoundException message+cause constructor"() {
given:
def cause = new RuntimeException("root")
def ex = new ResourceNotFoundException("not found", cause)

expect:
ex.getCause().is(cause)
ex.getStatus() == PathResponseStatus.NOT_FOUND
}

def "UnauthorizedException constructors"() {
given:
def ex = new UnauthorizedException("unauthorized", "please log in")

expect:
ex.getStatus() == PathResponseStatus.UNAUTHORIZED
ex.getUserMessage() == "please log in"
}

def "UnauthorizedException with cause"() {
given:
def cause = new RuntimeException("root")
def ex = new UnauthorizedException("unauthorized", "please log in", cause)

expect:
ex.getCause().is(cause)
ex.getStatus() == PathResponseStatus.UNAUTHORIZED
}

def "BadRequestException sets BAD_REQUEST status"() {
given:
def ex = new BadRequestException("bad input")

expect:
ex.getStatus() == PathResponseStatus.BAD_REQUEST
}

def "UpstreamResponseError single-arg constructor"() {
given:
def ex = new UpstreamResponseError("upstream error")

expect:
ex.getMessage() == "upstream error"
ex.shouldReport()
}

def "UpstreamResponseError with cause"() {
given:
def cause = new RuntimeException("root")
def ex = new UpstreamResponseError("upstream error", cause)

expect:
ex.getCause().is(cause)
}

def "RequestValidationException with message"() {
given:
def ex = new RequestValidationException("validation failed")

expect:
ex.getMessage() == "validation failed"
ex.getStatus() == PathResponseStatus.USER_ERROR
}

def "RequestValidationException with message and userMessage"() {
given:
def ex = new RequestValidationException("validation failed", "please fix input")

expect:
ex.getUserMessage() == "please fix input"
}

def "RequestPayloadException sets shouldReport=true and isInternal=true"() {
given:
def ex = new RequestPayloadException("payload error")

expect:
ex.getMessage() == "payload error"
ex.shouldReport()
ex.isInternal()
}

def "ResponsePayloadException sets shouldReport=true and isInternal=true"() {
given:
def ex = new ResponsePayloadException("response error")

expect:
ex.getMessage() == "response error"
ex.shouldReport()
ex.isInternal()
}

def "UpstreamResponseProcessingException constructors"() {
given:
def cause = new RuntimeException("root")

expect:
new UpstreamResponseProcessingException("processing error").getMessage() == "processing error"
new UpstreamResponseProcessingException("processing error", cause).getCause().is(cause)
}

def "UpstreamResponseValidationException constructors"() {
given:
def cause = new RuntimeException("root")

expect:
new UpstreamResponseValidationException("validation error").getMessage() == "validation error"
new UpstreamResponseValidationException("validation error", cause).getCause().is(cause)
}

def "UpstreamSystemUnavailable constructors"() {
given:
def cause = new RuntimeException("root")

expect:
new UpstreamSystemUnavailable("unavailable").getMessage() == "unavailable"
new UpstreamSystemUnavailable("unavailable", cause).getCause().is(cause)
new UpstreamSystemUnavailable("unavailable", "user msg").getUserMessage() == "user msg"
new UpstreamSystemUnavailable("unavailable", "user msg", cause).getCause().is(cause)
}

def "UpstreamSystemMaintenance sets errorTitle"() {
given:
def ex = new UpstreamSystemMaintenance("maintenance")

expect:
ex.getMessage() == "maintenance"
ex.getErrorTitle() == "System under maintenance"
}

def "UpstreamSystemMaintenance with cause"() {
given:
def cause = new RuntimeException("root")
def ex = new UpstreamSystemMaintenance("maintenance", cause)

expect:
ex.getCause().is(cause)
ex.getErrorTitle() == "System under maintenance"
}
}
Loading
Loading