Skip to content

Commit 130f9bf

Browse files
committed
Merge branch 'hotfix-1.27.6'
2 parents d881c77 + 3c7809c commit 130f9bf

21 files changed

+410
-360
lines changed

gemma-core/pom.xml

+34-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>gemma</artifactId>
55
<groupId>gemma</groupId>
6-
<version>1.27.5</version>
6+
<version>1.27.6</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>gemma-core</artifactId>
@@ -82,6 +82,8 @@
8282
<mainClass>ubic.gemma.core.apps.GemmaCLI</mainClass>
8383
</program>
8484
</programs>
85+
<!-- this allows Log4j 2 to lookup for Log4j 1.2 configuration -->
86+
<extraJvmArguments>-Dlog4j1.compatibility=true</extraJvmArguments>
8587
</configuration>
8688
<executions>
8789
<execution>
@@ -279,23 +281,53 @@
279281
<groupId>org.apache.jena</groupId>
280282
<artifactId>jena-core</artifactId>
281283
<version>2.7.4</version>
284+
<exclusions>
285+
<exclusion>
286+
<groupId>log4j</groupId>
287+
<artifactId>log4j</artifactId>
288+
</exclusion>
289+
<exclusion>
290+
<groupId>org.slf4j</groupId>
291+
<artifactId>slf4j-log4j12</artifactId>
292+
</exclusion>
293+
</exclusions>
282294
</dependency>
283295
<dependency>
284296
<groupId>org.apache.jena</groupId>
285297
<artifactId>jena-arq</artifactId>
286298
<version>2.9.4</version>
299+
<exclusions>
300+
<exclusion>
301+
<groupId>log4j</groupId>
302+
<artifactId>log4j</artifactId>
303+
</exclusion>
304+
<exclusion>
305+
<groupId>org.slf4j</groupId>
306+
<artifactId>slf4j-log4j12</artifactId>
307+
</exclusion>
308+
</exclusions>
287309
</dependency>
288310
<dependency>
289311
<groupId>org.apache.jena</groupId>
290312
<artifactId>jena-larq</artifactId>
291313
<version>1.0.0-incubating</version>
314+
<exclusions>
315+
<exclusion>
316+
<groupId>log4j</groupId>
317+
<artifactId>log4j</artifactId>
318+
</exclusion>
319+
<exclusion>
320+
<groupId>org.slf4j</groupId>
321+
<artifactId>slf4j-log4j12</artifactId>
322+
</exclusion>
323+
</exclusions>
292324
</dependency>
293325

294326
<!-- Compass (fork compatible with Lucene 3.6.2) -->
295327
<dependency>
296328
<groupId>ubc.chibi.compass-fork</groupId>
297329
<artifactId>compass-fork</artifactId>
298-
<version>1.1</version>
330+
<version>1.1.1</version>
299331
</dependency>
300332

301333
<!-- Apache Commons -->

gemma-core/src/main/java/ubic/gemma/core/job/TaskCommand.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class TaskCommand implements Serializable {
6565
/**
6666
* Used to propagate security to grid workers.
6767
*/
68-
private SecurityContext securityContext;
68+
private final Authentication authentication;
6969
private String submitter;
7070
private String taskId;
7171
/**
@@ -81,7 +81,7 @@ public TaskCommand() {
8181
// security details.
8282
SecurityContext context = SecurityContextHolder.getContext();
8383
assert context != null;
84-
this.securityContext = context;
84+
this.authentication = context.getAuthentication();
8585

8686
Authentication authentication = context.getAuthentication();
8787
// can happen in test situations.
@@ -148,8 +148,8 @@ public void setPersistJobDetails( Boolean persistJobDetails ) {
148148
this.persistJobDetails = persistJobDetails;
149149
}
150150

151-
public SecurityContext getSecurityContext() {
152-
return this.securityContext;
151+
public Authentication getAuthentication() {
152+
return this.authentication;
153153
}
154154

155155
/**

gemma-core/src/main/java/ubic/gemma/core/job/executor/common/ExecutingTask.java

+50-36
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package ubic.gemma.core.job.executor.common;
1616

17+
import org.springframework.security.core.Authentication;
1718
import org.springframework.security.core.context.SecurityContextHolder;
1819
import ubic.gemma.core.job.TaskCommand;
1920
import ubic.gemma.core.job.TaskResult;
@@ -31,10 +32,9 @@ public class ExecutingTask<T extends TaskResult> implements Callable<T> {
3132
private final Task<T, ?> task;
3233
private final String taskId;
3334
private final TaskCommand taskCommand;
35+
3436
// Does not survive serialization.
35-
private transient TaskLifecycleHandler statusCallback;
36-
private transient ProgressUpdateAppender progressAppender;
37-
private Throwable taskExecutionException;
37+
private transient TaskLifecycleHandler lifecycleHandler;
3838

3939
public ExecutingTask( Task<T, ?> task, TaskCommand taskCommand ) {
4040
this.task = task;
@@ -45,58 +45,72 @@ public ExecutingTask( Task<T, ?> task, TaskCommand taskCommand ) {
4545
@SuppressWarnings("unchecked")
4646
@Override
4747
public final T call() {
48-
this.setup();
49-
// From here we are running as user who submitted the task.
48+
T result;
49+
50+
if ( lifecycleHandler == null ) {
51+
throw new IllegalStateException( "No lifecycle handler has been configured for this executing task." );
52+
}
53+
54+
lifecycleHandler.onStart();
5055

51-
statusCallback.onStart();
56+
Authentication previousAuthentication = SecurityContextHolder.getContext().getAuthentication();
5257

53-
T result = null;
54-
try {
58+
try ( ProgressUpdateAppender.ProgressUpdateContext progressUpdateContext = new ProgressUpdateAppender.ProgressUpdateContext( lifecycleHandler::onProgress ) ) {
59+
// From here we are running as user who submitted the task.
60+
SecurityContextHolder.getContext().setAuthentication( taskCommand.getAuthentication() );
5561
result = this.task.execute();
5662
} catch ( Throwable e ) {
57-
statusCallback.onFailure( e );
58-
taskExecutionException = e;
63+
// result is an exception
64+
result = ( T ) new TaskResult( taskId );
65+
result.setException( e );
5966
} finally {
60-
this.cleanup();
67+
// restore the previous security context
68+
SecurityContextHolder.getContext().setAuthentication( previousAuthentication );
6169
}
62-
// SecurityContext is cleared at this point.
6370

64-
if ( taskExecutionException == null ) {
65-
statusCallback.onFinish();
66-
return result;
71+
if ( result.getException() == null ) {
72+
lifecycleHandler.onSuccess();
73+
} else {
74+
lifecycleHandler.onFailure( result.getException() );
6775
}
68-
result = ( T ) new TaskResult( taskId );
69-
result.setException( taskExecutionException );
70-
return result;
7176

72-
}
77+
lifecycleHandler.onComplete();
7378

74-
public void setProgressAppender( ProgressUpdateAppender progressAppender ) {
75-
this.progressAppender = progressAppender;
79+
return result;
7680
}
7781

78-
public void setStatusCallback( TaskLifecycleHandler statusCallback ) {
79-
this.statusCallback = statusCallback;
82+
public void setLifecycleHandler( TaskLifecycleHandler lifecycleHandler ) {
83+
this.lifecycleHandler = lifecycleHandler;
8084
}
8185

82-
private void cleanup() {
83-
SecurityContextHolder.clearContext();
84-
85-
progressAppender.tearDown();
86-
}
86+
// These hooks are used to update status of the running task.
87+
public interface TaskLifecycleHandler {
8788

88-
private void setup() {
89-
progressAppender.initialize();
89+
/**
90+
* Whenever the task execution begins.
91+
*/
92+
void onStart();
9093

91-
SecurityContextHolder.setContext( taskCommand.getSecurityContext() );
92-
}
94+
/**
95+
* When progress is made on the task.
96+
* @param message
97+
*/
98+
void onProgress( String message );
9399

94-
// These hooks are used to update status of the running task.
95-
public interface TaskLifecycleHandler {
100+
/**
101+
* On failure.
102+
* @param e
103+
*/
96104
void onFailure( Throwable e );
97105

98-
void onFinish();
106+
/**
107+
* On successful completion.
108+
*/
109+
void onSuccess();
99110

100-
void onStart();
111+
/**
112+
* On completion, regardless of failure.
113+
*/
114+
void onComplete();
101115
}
102116
}

gemma-core/src/main/java/ubic/gemma/core/job/executor/common/LogBasedProgressAppender.java

-84
This file was deleted.

0 commit comments

Comments
 (0)