[ https://issues.apache.org/jira/browse/JSPF-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17851130#comment-17851130 ]
Benoit Tellier commented on JSPF-110: ------------------------------------- Hello, I'm getting a further look at it. AsynchronousSPFExecutor and SynchronousSPFExecutor indeed may be affected by an infinite loop: {code:java} while (e != null) { while (checker == null || !(checker instanceof SPFCheckerExceptionCatcher)) { checker = session.popChecker(); } try { ((SPFCheckerExceptionCatcher) checker).onException(e, session); e = null; } catch (SPFResultException ex) { e = ex; } finally { checker = null; } } {code} The code explicitly rely on a checker on the stack to be present. The issue is that if no checker at all is present then the code would loop indefinitly and lead to the very issue you describe. This issue might be caused by errors in some specific checkers (in a position not covered by error handling?) but fine for others. The code in JSPF looks overly complicated to me for what it does, it is very hard to wrap my head around this execution flow... I bet the safest way to solve this would be: - 1. Extract the "get me the first checker of XYZ class" onto a separate SPFSession method.... - 2. Define a safe enough default behaviour to do when no explicit exception handling is found. A review of checkers onException... method might be helpful for that. - 3 Apply that behaviour Thought? > Infinite loop in the handleError method > --------------------------------------- > > Key: JSPF-110 > URL: https://issues.apache.org/jira/browse/JSPF-110 > Project: James jSPF > Issue Type: Bug > Components: Core > Affects Versions: master > Environment: Java: 21 > Spring Boot: 3.2.4 > Reporter: aleksey > Priority: Major > Labels: pull-request-available > > Hello, my dear friends! > I use your library to check SPF in my work. > {code:java} > <dependency> > <groupId>org.apache.james.jspf</groupId> > <artifactId>apache-jspf-resolver</artifactId> > <version>1.0.3</version> > </dependency> {code} > Here's an exact example of how I use it: > {code:java} > SPF spfChecker = new DefaultSPF(); > spfChecker.setUseBestGuess(true); > SPFResult spfResult = spfChecker.checkSPF(ipAddress, from, hostname); > return spfResult.getResult();{code} > And I have encountered a problem with the AsynchronousSPFExecutor: > {code:java} > "Thread-145410" #2022286 [1208634] daemon prio=5 os_prio=0 cpu=1337200.37ms > elapsed=1431.06s tid=0x00007f38240a8d20 nid=1208634 runnable > [0x00007f38353e1000] > java.lang.Thread.State: RUNNABLE > at > org.apache.james.jspf.executor.AsynchronousSPFExecutor.handleError(AsynchronousSPFExecutor.java:99) > at > org.apache.james.jspf.executor.AsynchronousSPFExecutor.lambda$execute$0(AsynchronousSPFExecutor.java:69) > at > org.apache.james.jspf.executor.AsynchronousSPFExecutor$$Lambda/0x00007f3838a5ea48.accept(Unknown > Source) > at > java.util.concurrent.CompletableFuture$UniAccept.tryFire(java.base@21.0.1/CompletableFuture.java:718) > at > java.util.concurrent.CompletableFuture.postComplete(java.base@21.0.1/CompletableFuture.java:510) > at > java.util.concurrent.CompletableFuture.postFire(java.base@21.0.1/CompletableFuture.java:614) > at > java.util.concurrent.CompletableFuture$UniCompose.tryFire(java.base@21.0.1/CompletableFuture.java:1163) > at > java.util.concurrent.CompletableFuture$Completion.run(java.base@21.0.1/CompletableFuture.java:482) > at java.lang.Thread.runWith(java.base@21.0.1/Thread.java:1596) > at java.lang.Thread.run(java.base@21.0.1/Thread.java:1583) {code} > This infinite loop is affecting the server. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org