forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes quarkusio#9327 fixes quarkusio#9328
- Loading branch information
1 parent
8ac1fb1
commit f256450
Showing
27 changed files
with
859 additions
and
105 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
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
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
36 changes: 36 additions & 0 deletions
36
...deployment/src/main/java/io/quarkus/grpc/deployment/devmode/FieldDefinalizingVisitor.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,36 @@ | ||
package io.quarkus.grpc.deployment.devmode; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.function.BiFunction; | ||
|
||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.FieldVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
import io.quarkus.gizmo.Gizmo; | ||
|
||
public class FieldDefinalizingVisitor implements BiFunction<String, ClassVisitor, ClassVisitor> { | ||
|
||
private final Set<String> fields = new HashSet<>(); | ||
|
||
public FieldDefinalizingVisitor(String... fields) { | ||
this.fields.addAll(asList(fields)); | ||
} | ||
|
||
@Override | ||
public ClassVisitor apply(String s, ClassVisitor classVisitor) { | ||
return new ClassVisitor(Gizmo.ASM_API_VERSION, classVisitor) { | ||
@Override | ||
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) { | ||
if (fields.contains(name)) { | ||
access = access & (~Opcodes.ACC_FINAL); | ||
access = access | Opcodes.ACC_VOLATILE; | ||
} | ||
return super.visitField(access, name, descriptor, signature, value); | ||
} | ||
}; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeTestInterceptor.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,36 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import io.grpc.ForwardingServerCall; | ||
import io.grpc.Metadata; | ||
import io.grpc.ServerCall; | ||
import io.grpc.ServerCallHandler; | ||
import io.grpc.ServerInterceptor; | ||
|
||
@ApplicationScoped | ||
public class DevModeTestInterceptor implements ServerInterceptor { | ||
|
||
private volatile String lastStatus = "initial"; | ||
|
||
@Override | ||
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, | ||
Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler) { | ||
return serverCallHandler | ||
.startCall(new ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(serverCall) { | ||
@Override | ||
protected ServerCall<ReqT, RespT> delegate() { | ||
lastStatus = getStatus(); | ||
return super.delegate(); | ||
} | ||
}, metadata); | ||
} | ||
|
||
public String getLastStatus() { | ||
return lastStatus; | ||
} | ||
|
||
private String getStatus() { | ||
return "status"; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeTestRestResource.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,33 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
* <br> | ||
* Date: 4/28/20 | ||
*/ | ||
@Path("/test") | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public class DevModeTestRestResource { | ||
|
||
@Inject | ||
DevModeTestInterceptor interceptor; | ||
|
||
@GET | ||
public String get() { | ||
return "testresponse"; | ||
} | ||
|
||
@GET | ||
@Path("/interceptor-status") | ||
public String getInterceptorStatus() { | ||
return interceptor.getLastStatus(); | ||
} | ||
} |
Oops, something went wrong.