Skip to content
Open
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaajaln2 , Could you please elaborate why you chose to return null on line 242? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JinwooHwang Since we are just retrieving the proxy class and no other behavior, the handler is a no-op. I had to add the handler in order to use non-deprecated method.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -232,7 +234,17 @@ public Class<?> getProxyClass(final Class<?>... classObjs) {

for (ClassLoader classLoader : getClassLoaders()) {
try {
return Proxy.getProxyClass(classLoader, classObjs);
// Proxy.getProxyClass is deprecated, so use the recommended way to create a proxy class.
// Only used to get the proxy class, so the handler can be a no-op.
InvocationHandler invocationHandler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] methodArgs) {
return null;
}
};
// create a new Proxy instance to get the proxy class
Object proxy = Proxy.newProxyInstance(classLoader, classObjs, invocationHandler);
return proxy.getClass();
} catch (SecurityException sex) {
// Continue to next classloader
} catch (IllegalArgumentException iaex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -164,27 +164,27 @@ public void configureConnection(ConnectionConfig connectionConfig) {
// Configure SSL context and hostname verifier (HttpClient 5.x approach)
// Only configure SSL if we have a non-null SSL context
if (connectionConfig.getSslContext() != null) {
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
DefaultClientTlsStrategy sslSocketFactory = new DefaultClientTlsStrategy(
connectionConfig.getSslContext(),
connectionConfig.getHostnameVerifier());

HttpClientConnectionManager connectionManager =
PoolingHttpClientConnectionManagerBuilder.create()
.setSSLSocketFactory(sslSocketFactory)
.setTlsSocketStrategy(sslSocketFactory)
.build();

clientBuilder.setConnectionManager(connectionManager);
} else if (connectionConfig.getHostnameVerifier() != null) {
// If only hostname verifier is set without SSL context, we need to use the default SSL
// context
try {
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
DefaultClientTlsStrategy sslSocketFactory = new DefaultClientTlsStrategy(
SSLContext.getDefault(),
connectionConfig.getHostnameVerifier());

HttpClientConnectionManager connectionManager =
PoolingHttpClientConnectionManagerBuilder.create()
.setSSLSocketFactory(sslSocketFactory)
.setTlsSocketStrategy(sslSocketFactory)
.build();

clientBuilder.setConnectionManager(connectionManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public String getRegionName() {
}

String regionName = regionPath.trim().split(" ")[0];
regionName = StringUtils.removeStart(regionName, SEPARATOR);
regionName =
regionName.startsWith(SEPARATOR) ? regionName.substring(SEPARATOR.length()) : regionName;
if (regionName.contains(".")) {
regionName = regionName.substring(0, regionName.indexOf('.'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,11 @@ public void register(int fixedId, Class<? extends DataSerializableFixedID> fixed
try {
Constructor<?> cons = fixedIdClass.getConstructor((Class<Object>[]) null);
cons.setAccessible(true);
if (!cons.isAccessible()) {
// Based on canAccess doc - since this is constructor, the obj must be null
if (!cons.canAccess(null)) {
throw new IllegalArgumentException(
"default constructor not accessible " + "for DSFID=" + fixedId + ": " + fixedIdClass);
"default constructor failed reflective access check (canAccess) for DSFID="
+ fixedId + ": " + fixedIdClass);
}
if (fixedId >= Byte.MIN_VALUE && fixedId <= Byte.MAX_VALUE) {
int index = fixedId + Byte.MAX_VALUE + 1;
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaajaln2 , Could you please share your reasoning behind these comments? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JinwooHwang For the deprecated method parser.setMatchOptionalTrailingSeparator(), I think we can wait until we upgrade to Spring 6.2+ and then switch to URLHandlerFilter

Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public class SwaggerConfig implements WebApplicationInitializer, WebMvcConfigure
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
PathPatternParser parser = new PathPatternParser();
// When Geode requires Spring Framework 6.2+ as a minimum, this explicit PathPatternParser
// configuration for optional trailing slashes can be replaced by configuring UrlHandlerFilter
// (e.g., via a filter registration or equivalent configuration) to handle trailing-slash
// matching instead of customize it here in configurePathMatch.
parser.setMatchOptionalTrailingSeparator(true);
configurer.setPatternParser(parser);
}
Expand Down
Loading