Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9CqW-00048q-ME for pgsql-general@arkaria.postgresql.org; Thu, 29 Jul 2021 20:41:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m9CqV-0006zv-9a for pgsql-general@arkaria.postgresql.org; Thu, 29 Jul 2021 20:41:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9CqU-0006zl-95 for pgsql-general@lists.postgresql.org; Thu, 29 Jul 2021 20:41:35 +0000 Received: from mail.simkorp.com.br ([177.52.183.219]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9CqK-0007KX-L3 for pgsql-general@lists.postgresql.org; Thu, 29 Jul 2021 20:41:33 +0000 Received: from mail.simkorp.com.br (mail.simkorp.com.br [127.0.0.1]) by mail.simkorp.com.br (Postfix) with ESMTP id 4GbMrH0wzpz6Vb6l for ; Thu, 29 Jul 2021 17:41:19 -0300 (-03) Authentication-Results: mail.simkorp.com.br (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=simkorp.com.br DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simkorp.com.br; h=content-transfer-encoding:content-language:content-type :content-type:in-reply-to:mime-version:user-agent:date:date :message-id:from:from:references:to:subject:subject; s=dkim; t= 1627591274; x=1630183275; bh=jiwrxNRYSn+RpAV4wAEnG6ujYLRg0dBnMRG UCYhPtro=; b=wfcrp48oEls3pLXrgN7OlIkc+sInjRWD4I/Z6sSi+TzK+K7sq+S S+CHzz6x4HYOeNe8HQPUdYFGe1bFwanff2iIoVXvVeWBWDsRSNAfnQqnXHE79HJd CWXq8pDLGLPwfXIGLCjJGNqVozsu22GMD5AmvrdyqqJ+v7hdmDZ6lUXk= X-Virus-Scanned: amavisd-new at mail.simkorp.com.br Received: from mail.simkorp.com.br ([127.0.0.1]) by mail.simkorp.com.br (mail.simkorp.com.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id N88sR0GTqLr1 for ; Thu, 29 Jul 2021 17:41:14 -0300 (-03) Received: from [192.168.0.30] (desktop [192.168.0.30]) by mail.simkorp.com.br (Postfix) with ESMTPSA id 4GbMrB3cKSz6TNRW for ; Thu, 29 Jul 2021 17:41:14 -0300 (-03) Subject: Re: Issue with PSQL JDBC Driver Null Pointer To: pgsql-general@lists.postgresql.org References: From: Edson Carlos Ericksson Richter Message-ID: Date: Thu, 29 Jul 2021 17:41:14 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: pt-BR Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I would do public String getTypeForAlias(String alias) { if (alias=3D=3Dnull) return null; // this shall solve NPE on=20 alias.toLowerCase() String type =3D TYPE_ALIASES.get(alias); if (type !=3D null) { return type; } type =3D TYPE_ALIASES.get(alias.toLowerCase()) *// NPE STILL HERE*; if (type =3D=3D null) { type =3D alias; } //populate for future use TYPE_ALIASES.put(alias, type); return type; } Em 29/07/2021 16:44, Bhavesh Mistry escreveu: > Hi Dave, > > It still does not address the NPE issue.=C2=A0 If an alias is NULL. Wha= t=20 > should be the behavior? > > > public String getTypeForAlias(String alias) { > > String type =3D TYPE_ALIASES.get(alias); > > if (type !=3D null) { > > return type; > > } > > type =3D TYPE_ALIASES.get(alias.toLowerCase()) *// NPE STILL HERE*; > > if (type =3D=3D null) { > > type =3D alias; > > } > > //populate for future use > > TYPE_ALIASES.put(alias, type); > > return type; > > } > > Thanks, > > Bhavesh > > On Thu, Jul 29, 2021 at 8:44 AM Dave Cramer=20 > wrote: > > > > On Thu, 29 Jul 2021 at 11:04, Bhavesh Mistry > > > wrote: > > Hello, > > I am getting an NPE exception in the JDBC driver 42.2.23. > > When the alias is null, NPE results.=C2=A0 Is it possible to ha= ndle > null value ? I have filled=C2=A0a bug against RCA > https://github.com/vladmihalcea/hibernate-types/issues/335 > . > But, I thought that PSQL Driver can handle it more gracefully. > > |Caused by: java.lang.NullPointerException: null at > org.postgresql.jdbc.TypeInfoCache.getTypeForAlias(TypeInfoCache= .java:675) > at > org.postgresql.jdbc.TypeInfoCache.getPGArrayType(TypeInfoCache.= java:519) > at > org.postgresql.jdbc.PgConnection.createArrayOf(PgConnection.jav= a:1375) > at > org.postgresql.jdbc.PgConnection.createArrayOf(PgConnection.jav= a:1399) > at > org.apache.commons.dbcp2.DelegatingConnection.createArrayOf(Del= egatingConnection.java:827) > at > org.apache.commons.dbcp2.DelegatingConnection.createArrayOf(Del= egatingConnection.java:827) > at > org.apache.commons.dbcp2.DelegatingConnection.createArrayOf(Del= egatingConnection.java:827) > at > com.vladmihalcea.hibernate.type.array.internal.ArraySqlTypeDesc= riptor$1.doBind(ArraySqlTypeDescriptor.java:36) > at > org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.= java:73) > at > org.hibernate.type.AbstractStandardBasicType.nullSafeSet(Abstra= ctStandardBasicType.java:276) > at > org.hibernate.type.AbstractStandardBasicType.nullSafeSet(Abstra= ctStandardBasicType.java:271) > at > org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSa= feSet(AbstractSingleColumnStandardBasicType.java:39) > at > org.hibernate.persister.entity.AbstractEntityPersister.dehydrat= e(AbstractEntityPersister.java:2995) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(A= bstractEntityPersister.java:3292) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(A= bstractEntityPersister.java:3828) > at > org.hibernate.action.internal.EntityInsertAction.execute(Entity= InsertAction.java:107) > at > org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue= .java:604) > at > org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(Ac= tionQueue.java:478) > at > java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:68= 4) > at > org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue= .java:475) > at > org.hibernate.event.internal.AbstractFlushingEventListener.perf= ormExecutions(AbstractFlushingEventListener.java:348) > at > org.hibernate.event.internal.DefaultFlushEventListener.onFlush(= DefaultFlushEventListener.java:40) > at > org.hibernate.event.service.internal.EventListenerGroupImpl.fir= eEventOnEachListener(EventListenerGroupImpl.java:102) > at > org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:136= 2) > at > org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.jav= a:453) > at > org.hibernate.internal.SessionImpl.flushBeforeTransactionComple= tion(SessionImpl.java:3212) > at > org.hibernate.internal.SessionImpl.beforeTransactionCompletion(= SessionImpl.java:2380) > at > org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTr= ansactionCompletion(JdbcCoordinatorImpl.java:447) > at > org.hibernate.resource.transaction.backend.jdbc.internal.JdbcRe= sourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResour= ceLocalTransactionCoordinatorImpl.java:183) > at > org.hibernate.resource.transaction.backend.jdbc.internal.JdbcRe= sourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransac= tionCoordinatorImpl.java:40) > at > org.hibernate.resource.transaction.backend.jdbc.internal.JdbcRe= sourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit= (JdbcResourceLocalTransactionCoordinatorImpl.java:281) > at > org.hibernate.engine.transaction.internal.TransactionImpl.commi= t(TransactionImpl.java:101) > ... 123 common frames omitted| > > |public String getTypeForAlias(String alias) { String type =3D > typeAliases.get(alias); if (type !=3D null) { return type; } if > (alias.indexOf('"') =3D=3D -1) { *// THIS LINE THROWS NPE SINCE > alias is null ** * type =3D > typeAliases.get(alias.toLowerCase()); if (type !=3D null) { > return type; } } return alias; }| > > > It would appear that improv: type alias handling in TypeInfoCache > by bokken =C2=B7 Pull Request #1986 =C2=B7 pgjdbc/pgjdbc (github.co= m) > > should be backpatched into 42.2.24 which should solve this problem > > > Thanks, > Dave > > > --=20 > Thanks, > > Bhavesh > > > > --=20 > Thanks, > > Bhavesh >