Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-5768 Clustered CDI Events not Received if Sender Application Deployed on Receiver Instance #5435

Merged
merged 4 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016-2020 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -170,7 +170,7 @@ public Class<? extends Annotation> annotationType() {
bm.fireEvent(eventPayload,annotations);
} catch (IOException | ClassNotFoundException ex) {
Logger.getLogger(ClusteredCDIEventBusImpl.class.getName())
.log(ex.getCause() instanceof IllegalStateException? Level.FINE : Level.INFO,
.log(ex.getCause() instanceof IllegalStateException ? Level.FINE : Level.INFO,
"Received Event but could not process it", ex);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -41,7 +41,7 @@

import com.sun.enterprise.util.Utility;
import fish.payara.micro.event.PayaraClusteredCDIEvent;
import fish.payara.cdi.jsr107.implementation.PayaraValueHolder;
import fish.payara.appserver.micro.services.data.PayaraValueHolder;
import fish.payara.micro.data.InstanceDescriptor;
import java.io.IOException;
import java.io.Serializable;
Expand Down Expand Up @@ -172,7 +172,8 @@ public Set<Annotation> getQualifiers() {
// then create a proxy for the annotation type from the serialized Invocation Handler
result.add((Annotation) Proxy.newProxyInstance(Utility.getClassLoader(), new Class[]{annotationClazz}, qualifier));
} catch (Throwable ex) {
Logger.getLogger(PayaraClusteredCDIEventImpl.class.getName()).log(Level.INFO, "Problem determining the qualifier type of an Event ignoring", ex);
Logger.getLogger(PayaraClusteredCDIEventImpl.class.getName()).log(Level.INFO,
"Problem determining the qualifier type of an Event, ignoring", ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016-2020 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -37,7 +37,11 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.cdi.jsr107.implementation;
package fish.payara.appserver.micro.services.data;

import fish.payara.cdi.jsr107.implementation.PayaraTCCLObjectInputStream;
import org.glassfish.internal.api.Globals;
import org.glassfish.internal.api.JavaEEContextUtil;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand All @@ -46,10 +50,6 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Optional;
import org.glassfish.internal.api.Globals;
import org.glassfish.internal.api.JavaEEContextUtil;
import org.glassfish.internal.api.JavaEEContextUtil.Context;

/**
* Packages up an object into a Serializable value
Expand Down Expand Up @@ -79,12 +79,8 @@ public T getValue() throws IOException, ClassNotFoundException {
String componentId = null;
try (ByteArrayInputStream bais = new ByteArrayInputStream(data); PayaraTCCLObjectInputStream ois = new PayaraTCCLObjectInputStream(bais)) {
componentId = (String)ois.readObject();
JavaEEContextUtil ctxUtil = Globals.getDefaultHabitat().getService(JavaEEContextUtil.class);
JavaEEContextUtil.Instance inst = Optional.ofNullable(componentId)
.map(ctxUtil::fromComponentId).orElse(ctxUtil.empty());
try (Context ctx = inst.setApplicationClassLoader()) {
return (T) ois.readObject();
}
Object result = ois.readObject();
return (T)result;
}
catch (ClassNotFoundException ex) {
String invocationComponentId = Globals.getDefaultHabitat().getService(JavaEEContextUtil.class).getInvocationComponentId();
Expand Down