public inbox for [email protected]  
help / color / mirror / Atom feed
Duplicate Proxy.newProxyInstance calls during PGXAConnection.getConnection?
2+ messages / 1 participants
[nested] [flat]

* Duplicate Proxy.newProxyInstance calls during PGXAConnection.getConnection?
@ 2023-03-26 07:16  Andy Fan <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Andy Fan @ 2023-03-26 07:16 UTC (permalink / raw)
  To: [email protected]

In the PGXAConnection.GetConnection() [1], we can see the below code:

  @Override
  public Connection getConnection() throws SQLException {

    // *the first time ConnectionHandler has been created.*
    Connection conn = super.getConnection();

    // When we're outside an XA transaction, autocommit
    // is supposed to be true, per usual JDBC convention.
    // When an XA transaction is in progress, it should be
    // false.
    if (state == State.IDLE) {
      conn.setAutoCommit(true);
    }

    /*
     * Wrap the connection in a proxy to forbid application from
fiddling with transaction state
     * directly during an XA transaction
     */

    // *ConnectionHandler is created again here. *
    ConnectionHandler handler = new ConnectionHandler(conn);
    return (Connection) Proxy.newProxyInstance(getClass().getClassLoader(),
        new Class[]{Connection.class, PGConnection.class}, handler);
  }


However I think the proxy has already been created at the first line:
super.getConnection(),
and then it is created later.  Is it a duplication?

[1]
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/xa/PGXAConnection.j...


-- 
Best Regards
Andy Fan


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Duplicate Proxy.newProxyInstance calls during PGXAConnection.getConnection?
@ 2023-03-26 08:16  Andy Fan <[email protected]>
  parent: Andy Fan <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Andy Fan @ 2023-03-26 08:16 UTC (permalink / raw)
  To: [email protected]

Please forgive me, I was totally wrong here.  Sorry for the noise.

On Sun, Mar 26, 2023 at 3:16 PM Andy Fan <[email protected]> wrote:

> In the PGXAConnection.GetConnection() [1], we can see the below code:
>
>   @Override
>   public Connection getConnection() throws SQLException {
>
>     // *the first time ConnectionHandler has been created.*
>     Connection conn = super.getConnection();
>
>     // When we're outside an XA transaction, autocommit
>     // is supposed to be true, per usual JDBC convention.
>     // When an XA transaction is in progress, it should be
>     // false.
>     if (state == State.IDLE) {
>       conn.setAutoCommit(true);
>     }
>
>     /*
>      * Wrap the connection in a proxy to forbid application from fiddling with transaction state
>      * directly during an XA transaction
>      */
>
>     // *ConnectionHandler is created again here. *
>     ConnectionHandler handler = new ConnectionHandler(conn);
>     return (Connection) Proxy.newProxyInstance(getClass().getClassLoader(),
>         new Class[]{Connection.class, PGConnection.class}, handler);
>   }
>
>
> However I think the proxy has already been created at the first line:
> super.getConnection(),
> and then it is created later.  Is it a duplication?
>
> [1]
> https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/xa/PGXAConnection.j...
>
>
> --
> Best Regards
> Andy Fan
>


-- 
Best Regards
Andy Fan


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2023-03-26 08:16 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-26 07:16 Duplicate Proxy.newProxyInstance calls during PGXAConnection.getConnection? Andy Fan <[email protected]>
2023-03-26 08:16 ` Andy Fan <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox