-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14952 from stuartwdouglas/class-loader-fix
Fix ClassLoader getParent() hack
- Loading branch information
Showing
8 changed files
with
218 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...n/java/io/quarkus/mutiny/reactive/operators/runtime/ReactiveStreamsOperatorsRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.quarkus.mutiny.reactive.operators.runtime; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Enumeration; | ||
|
||
import org.eclipse.microprofile.reactive.streams.operators.core.ReactiveStreamsEngineResolver; | ||
import org.eclipse.microprofile.reactive.streams.operators.spi.ReactiveStreamsFactoryResolver; | ||
|
||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class ReactiveStreamsOperatorsRecorder { | ||
|
||
/** | ||
* ClassLoader hack to work around reactive streams API issue | ||
* see https://github.com/eclipse/microprofile-reactive-streams-operators/pull/130 | ||
* | ||
* This must be deleted when Reactive Streams Operators 1.1 is merged | ||
*/ | ||
public void classLoaderHack() { | ||
ClassLoader cl = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
Thread.currentThread().setContextClassLoader(new ClassLoader(null) { | ||
@Override | ||
public Class<?> loadClass(String name) throws ClassNotFoundException { | ||
return cl.loadClass(name); | ||
} | ||
|
||
@Override | ||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { | ||
return cl.loadClass(name); | ||
} | ||
|
||
@Override | ||
public URL getResource(String name) { | ||
return cl.getResource(name); | ||
} | ||
|
||
@Override | ||
public Enumeration<URL> getResources(String name) throws IOException { | ||
return cl.getResources(name); | ||
} | ||
|
||
@Override | ||
public InputStream getResourceAsStream(String name) { | ||
return cl.getResourceAsStream(name); | ||
} | ||
}); | ||
ReactiveStreamsFactoryResolver.instance(); | ||
ReactiveStreamsEngineResolver.instance(); | ||
} finally { | ||
Thread.currentThread().setContextClassLoader(cl); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...o/quarkus/smallrye/reactivestreamsoperators/runtime/ReactiveStreamsOperatorsRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.quarkus.smallrye.reactivestreamsoperators.runtime; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Enumeration; | ||
|
||
import org.eclipse.microprofile.reactive.streams.operators.core.ReactiveStreamsEngineResolver; | ||
import org.eclipse.microprofile.reactive.streams.operators.spi.ReactiveStreamsFactoryResolver; | ||
|
||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class ReactiveStreamsOperatorsRecorder { | ||
|
||
/** | ||
* ClassLoader hack to work around reactive streams API issue | ||
* see https://github.com/eclipse/microprofile-reactive-streams-operators/pull/130 | ||
* | ||
* This must be deleted when Reactive Streams Operators 1.1 is merged | ||
*/ | ||
public void classLoaderHack() { | ||
ClassLoader cl = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
Thread.currentThread().setContextClassLoader(new ClassLoader(null) { | ||
@Override | ||
public Class<?> loadClass(String name) throws ClassNotFoundException { | ||
return cl.loadClass(name); | ||
} | ||
|
||
@Override | ||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { | ||
return cl.loadClass(name); | ||
} | ||
|
||
@Override | ||
public URL getResource(String name) { | ||
return cl.getResource(name); | ||
} | ||
|
||
@Override | ||
public Enumeration<URL> getResources(String name) throws IOException { | ||
return cl.getResources(name); | ||
} | ||
|
||
@Override | ||
public InputStream getResourceAsStream(String name) { | ||
return cl.getResourceAsStream(name); | ||
} | ||
}); | ||
ReactiveStreamsFactoryResolver.instance(); | ||
ReactiveStreamsEngineResolver.instance(); | ||
} finally { | ||
Thread.currentThread().setContextClassLoader(cl); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
@ApplicationScoped | ||
public class SuffixService { | ||
|
||
public String getSuffix() { | ||
String getSuffix() { | ||
return ""; | ||
} | ||
} |