This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new ed18b53b67 ARTEMIS-5829 cache reflection methods on 
PostgresLargeObjectManager
ed18b53b67 is described below

commit ed18b53b67eac3062a7e44d753bc2d3149273b5c
Author: Clebert Suconic <[email protected]>
AuthorDate: Fri Dec 19 12:15:32 2025 -0500

    ARTEMIS-5829 cache reflection methods on PostgresLargeObjectManager
    
    notice there are no semantic changes here.
    Reflection is probably only used as part of our testsuite because of 
casspath
    issues.
---
 .../store/file/PostgresLargeObjectManager.java     | 63 +++++++++++++++-------
 1 file changed, 45 insertions(+), 18 deletions(-)

diff --git 
a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/PostgresLargeObjectManager.java
 
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/PostgresLargeObjectManager.java
index c81da2b28c..2994e4bc7f 100644
--- 
a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/PostgresLargeObjectManager.java
+++ 
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/PostgresLargeObjectManager.java
@@ -57,12 +57,15 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method createLOMethod;
    public final Long createLO(Connection connection) throws SQLException {
       if (shouldUseReflection) {
          Object largeObjectManager = getLargeObjectManager(connection);
          try {
-            Method method = 
largeObjectManager.getClass().getMethod("createLO");
-            return (Long) method.invoke(largeObjectManager);
+            if (createLOMethod == null) {
+               createLOMethod = 
largeObjectManager.getClass().getMethod("createLO");
+            }
+            return (Long) createLOMethod.invoke(largeObjectManager);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObjectManager", ex);
          }
@@ -71,12 +74,15 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method deleteLOMethod;
    public final void deleteLO(Connection connection, long oid) throws 
SQLException {
       Object largeObjectManager = getLargeObjectManager(connection);
       if (shouldUseReflection) {
          try {
-            Method method = largeObjectManager.getClass().getMethod("delete", 
long.class);
-            method.invoke(largeObjectManager, oid);
+            if (deleteLOMethod == null) {
+               deleteLOMethod = 
largeObjectManager.getClass().getMethod("delete", long.class);
+            }
+            deleteLOMethod.invoke(largeObjectManager, oid);
          } catch (Exception ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObjectManager", ex);
          }
@@ -88,12 +94,15 @@ public class PostgresLargeObjectManager {
 
    }
 
+   volatile Method openMethod;
    public Object open(Connection connection, long oid, int mode) throws 
SQLException {
       if (shouldUseReflection) {
          Object largeObjectManager = getLargeObjectManager(connection);
          try {
-            Method method = largeObjectManager.getClass().getMethod("open", 
long.class, int.class);
-            return method.invoke(largeObjectManager, oid, mode);
+            if (openMethod == null) {
+               openMethod = largeObjectManager.getClass().getMethod("open", 
long.class, int.class);
+            }
+            return openMethod.invoke(largeObjectManager, oid, mode);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObjectManager", ex);
          }
@@ -102,11 +111,14 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method sizeMethod;
    public int size(Object largeObject) throws SQLException {
       if (shouldUseReflection) {
          try {
-            Method method = largeObject.getClass().getMethod("size");
-            return (int) method.invoke(largeObject);
+            if (sizeMethod == null) {
+               sizeMethod = largeObject.getClass().getMethod("size");
+            }
+            return (int) sizeMethod.invoke(largeObject);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObject", ex);
          }
@@ -115,11 +127,14 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method closeMethod;
    public void close(Object largeObject) throws SQLException {
       if (shouldUseReflection) {
          try {
-            Method method = largeObject.getClass().getMethod("close");
-            method.invoke(largeObject);
+            if (closeMethod == null) {
+               closeMethod = largeObject.getClass().getMethod("close");
+            }
+            closeMethod.invoke(largeObject);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObject", ex);
          }
@@ -128,11 +143,14 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method readMethod;
    public byte[] read(Object largeObject, int length) throws SQLException {
       if (shouldUseReflection) {
          try {
-            Method method = largeObject.getClass().getMethod("read", 
int.class);
-            return (byte[]) method.invoke(largeObject, length);
+            if (readMethod == null) {
+               readMethod = largeObject.getClass().getMethod("read", 
int.class);
+            }
+            return (byte[]) readMethod.invoke(largeObject, length);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObject", ex);
          }
@@ -141,11 +159,14 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method writeMethod;
    public void write(Object largeObject, byte[] data) throws SQLException {
       if (shouldUseReflection) {
          try {
-            Method method = largeObject.getClass().getMethod("write", 
byte[].class);
-            method.invoke(largeObject, data);
+            if (writeMethod == null) {
+               writeMethod = largeObject.getClass().getMethod("write", 
byte[].class);
+            }
+            writeMethod.invoke(largeObject, data);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObject", ex);
          }
@@ -154,11 +175,14 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method seekMethod;
    public void seek(Object largeObject, int position) throws SQLException {
       if (shouldUseReflection) {
          try {
-            Method method = largeObject.getClass().getMethod("seek", 
int.class);
-            method.invoke(largeObject, position);
+            if (seekMethod == null) {
+               seekMethod = largeObject.getClass().getMethod("seek", 
int.class);
+            }
+            seekMethod.invoke(largeObject, position);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObject", ex);
          }
@@ -167,11 +191,14 @@ public class PostgresLargeObjectManager {
       }
    }
 
+   volatile Method truncateMethod;
    public void truncate(Object largeObject, int position) throws SQLException {
       if (shouldUseReflection) {
          try {
-            Method method = largeObject.getClass().getMethod("truncate", 
int.class);
-            method.invoke(largeObject, position);
+            if (truncateMethod == null) {
+               truncateMethod = largeObject.getClass().getMethod("truncate", 
int.class);
+            }
+            truncateMethod.invoke(largeObject, position);
          } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException | IllegalArgumentException | InvocationTargetException 
ex) {
             throw new SQLException("Couldn't access 
org.postgresql.largeobject.LargeObject", ex);
          }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to