15
15
import java .util .function .Function ;
16
16
import java .util .stream .Collectors ;
17
17
18
+ import oracle .kubernetes .operator .logging .LoggingFacade ;
19
+ import oracle .kubernetes .operator .logging .LoggingFactory ;
20
+ import oracle .kubernetes .operator .logging .MessageKeys ;
21
+
18
22
/**
19
23
* ContainerResolver based on {@link ThreadLocal}.
20
24
* <p>
34
38
* </pre>
35
39
*/
36
40
public class ThreadLocalContainerResolver extends ContainerResolver {
41
+ private static final LoggingFacade LOGGER = LoggingFactory .getLogger ("Operator" , "Operator" );
42
+
37
43
private ThreadLocal <Container > containerThreadLocal = new ThreadLocal <Container >() {
38
44
@ Override
39
45
protected Container initialValue () {
@@ -78,6 +84,15 @@ ScheduledExecutorService wrapExecutor(final Container container, final Scheduled
78
84
Container old = enterContainer (container );
79
85
try {
80
86
x .run ();
87
+ } catch (RuntimeException runtime ) {
88
+ LOGGER .severe (MessageKeys .EXCEPTION , runtime );
89
+ throw runtime ;
90
+ } catch (Error error ) {
91
+ LOGGER .severe (MessageKeys .EXCEPTION , error );
92
+ throw error ;
93
+ } catch (Throwable throwable ) {
94
+ LOGGER .severe (MessageKeys .EXCEPTION , throwable );
95
+ throw new RuntimeException (throwable );
81
96
} finally {
82
97
exitContainer (old );
83
98
}
@@ -89,6 +104,15 @@ ScheduledExecutorService wrapExecutor(final Container container, final Scheduled
89
104
Container old = enterContainer (container );
90
105
try {
91
106
return x .call ();
107
+ } catch (RuntimeException runtime ) {
108
+ LOGGER .severe (MessageKeys .EXCEPTION , runtime );
109
+ throw runtime ;
110
+ } catch (Error error ) {
111
+ LOGGER .severe (MessageKeys .EXCEPTION , error );
112
+ throw error ;
113
+ } catch (Throwable throwable ) {
114
+ LOGGER .severe (MessageKeys .EXCEPTION , throwable );
115
+ throw new RuntimeException (throwable );
92
116
} finally {
93
117
exitContainer (old );
94
118
}
0 commit comments