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

Issue 1134 Map inet type to InetAddress #1527

Merged
merged 10 commits into from Jul 23, 2019
Merged

Conversation

@myowaithant9
Copy link
Contributor

@myowaithant9 myowaithant9 commented Jul 12, 2019

It was testing by creating separate JPA project with select query. Then, check the type and transform into InetAddress. For eg. the result data is /127.0.0.1 and type is class java.net.Inet4Address

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 12, 2019

Loading

@davecramer
Copy link
Member

@davecramer davecramer commented Jul 12, 2019

This fails all tests

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 16, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 16, 2019

Loading

@codecov-io
Copy link

@codecov-io codecov-io commented Jul 16, 2019

Codecov Report

Merging #1527 into master will increase coverage by 0.18%.
The diff coverage is 66.66%.

@@             Coverage Diff              @@
##             master    #1527      +/-   ##
============================================
+ Coverage     68.81%   68.99%   +0.18%     
- Complexity     3941     3959      +18     
============================================
  Files           179      179              
  Lines         16480    16489       +9     
  Branches       2676     2678       +2     
============================================
+ Hits          11340    11376      +36     
+ Misses         3891     3871      -20     
+ Partials       1249     1242       -7

Loading

@myowaithant9
Copy link
Contributor Author

@myowaithant9 myowaithant9 commented Jul 16, 2019

@davecramer I modified them and passed all tests. Could you please check again?

Loading

@@ -793,6 +793,7 @@ private Object buildArray(PgArrayList input, int index, int count) throws SQLExc

throw org.postgresql.Driver.notImplemented(this.getClass(), "getArrayImpl(long,int,Map)");
}
System.out.println("testing get object data in pgarray-->" + ret);
Copy link
Member

@davecramer davecramer Jul 16, 2019

Choose a reason for hiding this comment

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

Please remove any System.out.println use logging instead

Loading

Copy link
Contributor Author

@myowaithant9 myowaithant9 Jul 16, 2019

Choose a reason for hiding this comment

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

@davecramer It is the outdated version and I have already removed System.out.println. Could you please check overall commit? There are only 2 files I have changed, PgConnection and PgResultSet. So, do I still need to use logging for PgArray?

Loading

@@ -542,15 +544,27 @@ public LargeObjectManager getLargeObjectAPI() throws SQLException {
public Object getObject(String type, String value, byte[] byteValue) throws SQLException {
if (typemap != null) {
Class<?> c = typemap.get(type);
System.out.println("check type c in getOject in PgConnection : " + c);
Copy link
Member

@davecramer davecramer Jul 16, 2019

Choose a reason for hiding this comment

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

use logger instead

Loading

try {
return InetAddress.getByName(value);
} catch (UnknownHostException e) {
throw new PSQLException(GT.tr("Return Inet address is not supported.", type),
Copy link
Member

@davecramer davecramer Jul 17, 2019

Choose a reason for hiding this comment

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

This is a confusing message. If it is indeed an unknown host, why return Inet address not supported ?

Loading

Copy link
Contributor Author

@myowaithant9 myowaithant9 Jul 18, 2019

Choose a reason for hiding this comment

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

Oh! I am sorry for my mistake. It should be IP address of a host could not be determined

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 18, 2019

Loading

try {
return InetAddress.getByName(value);
} catch (UnknownHostException e) {
throw new PSQLException(GT.tr("IP address of a host could not be determined", type),
Copy link
Member

@davecramer davecramer Jul 18, 2019

Choose a reason for hiding this comment

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

for debugging purposes it would be useful to include the value of the host in the Exception.

Loading

Copy link
Contributor Author

@myowaithant9 myowaithant9 Jul 19, 2019

Choose a reason for hiding this comment

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

@davecramer Thanks for your suggestion and I have changed a little bit.

Loading

Copy link
Member

@davecramer davecramer Jul 21, 2019

Choose a reason for hiding this comment

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

Why not add the hostname instead ?

Loading

Copy link
Contributor Author

@myowaithant9 myowaithant9 Jul 22, 2019

Choose a reason for hiding this comment

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

@davecramer To get hostName from IP Address is like below:

InetAddress addr = InetAddress.getByName("192.168.190.62");
String host = addr.getHostName();
System.out.println(host);

So, I use InetAddress.getByName(value).getHostName() in Exception. But when I add that code, it shows me error to add throw declaration again. If I add it, the other files such as PgArray and PgResultset got error because of that declaration. That's why I use value only in Exception.

Loading

Copy link
Member

@davecramer davecramer Jul 22, 2019

Choose a reason for hiding this comment

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

Yes, I do want just the value. If I'm not mistaken the code above has type not value

Loading

Copy link
Contributor Author

@myowaithant9 myowaithant9 Jul 22, 2019

Choose a reason for hiding this comment

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

@davecramer If so, I have already changed it in my last commit.
throw new PSQLException(GT.tr("IP address {0} of a host could not be determined", value)

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 19, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 19, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 22, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 22, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 22, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 22, 2019

Loading

@davecramer
Copy link
Member

@davecramer davecramer commented Jul 22, 2019

Excellent. When it passes CI I will push it

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 22, 2019

Loading

@AppVeyorBot
Copy link

@AppVeyorBot AppVeyorBot commented Jul 23, 2019

Loading

@myowaithant9
Copy link
Contributor Author

@myowaithant9 myowaithant9 commented Jul 23, 2019

@davecramer It passed all tests.

Loading

@davecramer davecramer merged commit 1d0c477 into pgjdbc:master Jul 23, 2019
3 checks passed
Loading
@myowaithant9 myowaithant9 deleted the issue1134 branch Jul 23, 2019
maxcom added a commit to maxcom/lorsource that referenced this issue Sep 12, 2019
davecramer added a commit to davecramer/pgjdbc that referenced this issue Jul 5, 2021
* added getInetAddress function and throw Exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants