Skip to content

Commit c343a85

Browse files
authored
Merge branch 'master' into SpringBootRest
2 parents 0cd3f2b + cc37a01 commit c343a85

File tree

55 files changed

+785
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+785
-307
lines changed

android/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<groupId>commons-io</groupId>
2424
<artifactId>commons-io</artifactId>
2525
</exclusion>
26+
<exclusion> <!-- exclude bouncycastle from android -->
27+
<groupId>org.bouncycastle</groupId>
28+
<artifactId>bcprov-jdk15on</artifactId>
29+
</exclusion>
2630
</exclusions>
2731
</dependency>
2832
<dependency>
@@ -34,6 +38,10 @@
3438
<groupId>commons-io</groupId>
3539
<artifactId>commons-io</artifactId>
3640
</exclusion>
41+
<exclusion> <!-- exclude bouncycastle from android -->
42+
<groupId>org.bouncycastle</groupId>
43+
<artifactId>bcprov-jdk15on</artifactId>
44+
</exclusion>
3745
</exclusions>
3846
</dependency>
3947
<dependency>
@@ -58,6 +66,13 @@
5866
<artifactId>commons-io</artifactId>
5967
<version>2.2</version>
6068
</dependency>
69+
<!-- add explicit bouncycastle in Android, version used in Android Flexible client -->
70+
<!-- keep in sync version here and in Android Flexible client -->
71+
<dependency>
72+
<groupId>org.bouncycastle</groupId>
73+
<artifactId>bcprov-jdk15on</artifactId>
74+
<version>1.65</version>
75+
</dependency>
6176

6277
</dependencies>
6378

common/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@
4545
<artifactId>bcprov-jdk15on</artifactId>
4646
<version>1.69</version>
4747
</dependency>
48-
</dependencies>
48+
<dependency>
49+
<groupId>io.opentelemetry</groupId>
50+
<artifactId>opentelemetry-api</artifactId>
51+
<version>${io.opentelemetry.version}</version>
52+
</dependency>
53+
</dependencies>
4954

5055
<build>
5156
<finalName>gxcommon</finalName>

common/src/main/java/HTTPClient/HTTPConnection.java

Lines changed: 82 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,11 +3192,11 @@ Response sendRequest(Request req, int con_timeout)
31923192

31933193
while (try_count-- > 0)
31943194
{
3195+
Socket sock = null;
31953196
try
31963197
{
31973198
// get a client socket
31983199

3199-
Socket sock;
32003200
if (input_demux == null ||
32013201
(sock = input_demux.getSocket()) == null)
32023202
{
@@ -3323,6 +3323,10 @@ Response sendRequest(Request req, int con_timeout)
33233323
Log.write(Log.CONN, "Conn: Retrying request");
33243324
continue;
33253325
}
3326+
finally
3327+
{
3328+
if (sock != null) sock.close();
3329+
}
33263330

33273331
break;
33283332
}
@@ -3402,39 +3406,40 @@ Response sendRequest(Request req, int con_timeout)
34023406
*/
34033407
private Socket getSocket(int con_timeout) throws IOException
34043408
{
3405-
Socket sock = null;
3409+
Socket sock = null;
3410+
try {
34063411

3407-
String actual_host;
3408-
int actual_port;
3412+
String actual_host;
3413+
int actual_port;
34093414

3410-
if (Proxy_Host != null)
3411-
{
3412-
actual_host = Proxy_Host;
3413-
actual_port = Proxy_Port;
3414-
}
3415-
else
3416-
{
3417-
actual_host = Host;
3418-
actual_port = Port;
3419-
}
3415+
if (Proxy_Host != null)
3416+
{
3417+
actual_host = Proxy_Host;
3418+
actual_port = Proxy_Port;
3419+
}
3420+
else
3421+
{
3422+
actual_host = Host;
3423+
actual_port = Port;
3424+
}
34203425

3421-
Log.write(Log.CONN, "Conn: Creating Socket: " + actual_host + ":" +
3422-
actual_port);
3426+
Log.write(Log.CONN, "Conn: Creating Socket: " + actual_host + ":" +
3427+
actual_port);
34233428

3424-
if (con_timeout == 0) // normal connection establishment
3425-
{
3426-
if (Socks_client != null)
3427-
sock = Socks_client.getSocket(actual_host, actual_port);
3428-
else
3429-
{
3430-
// try all A records
3431-
InetAddress[] addr_list = InetAddress.getAllByName(actual_host);
3432-
for (int idx=0; idx<addr_list.length; idx++)
3433-
{
3434-
try
3435-
{
3436-
if (Protocol == HTTPS)
3429+
if (con_timeout == 0) // normal connection establishment
34373430
{
3431+
if (Socks_client != null)
3432+
sock = Socks_client.getSocket(actual_host, actual_port);
3433+
else
3434+
{
3435+
// try all A records
3436+
InetAddress[] addr_list = InetAddress.getAllByName(actual_host);
3437+
for (int idx=0; idx<addr_list.length; idx++)
3438+
{
3439+
try
3440+
{
3441+
if (Protocol == HTTPS)
3442+
{
34383443
//@gusbro
34393444
/* if (LocalAddr == null)
34403445
sock = new SSLSocket(addr_list[idx], actual_port,
@@ -3445,58 +3450,63 @@ private Socket getSocket(int con_timeout) throws IOException
34453450
ssl_ctxt);
34463451
((SSLSocket) sock).setAutoHandshake(false);
34473452
*/
3448-
if(LocalAddr == null)
3449-
sock = sslConnection.getSSLSocket(addr_list[idx], actual_port);
3450-
else sock = sslConnection.getSSLSocket(addr_list[idx], actual_port, LocalAddr, LocalPort);
3453+
if(LocalAddr == null)
3454+
sock = sslConnection.getSSLSocket(addr_list[idx], actual_port);
3455+
else sock = sslConnection.getSSLSocket(addr_list[idx], actual_port, LocalAddr, LocalPort);
34513456

3452-
//@iroqueta
3453-
sock.setTcpNoDelay(tcpNoDelay);
3457+
//@iroqueta
3458+
sock.setTcpNoDelay(tcpNoDelay);
34543459
//@gusbro\
3460+
}
3461+
else
3462+
{
3463+
if (LocalAddr == null)
3464+
sock = new Socket(addr_list[idx], actual_port);
3465+
else
3466+
sock = new Socket(addr_list[idx], actual_port,
3467+
LocalAddr, LocalPort);
3468+
//@iroqueta
3469+
sock.setTcpNoDelay(tcpNoDelay);
3470+
}
3471+
break; // success
3472+
}
3473+
catch (SocketException se)
3474+
{
3475+
if (idx == addr_list.length-1)
3476+
throw se; // we tried them all
3477+
}
3478+
}
3479+
}
34553480
}
34563481
else
34573482
{
3458-
if (LocalAddr == null)
3459-
sock = new Socket(addr_list[idx], actual_port);
3460-
else
3461-
sock = new Socket(addr_list[idx], actual_port,
3462-
LocalAddr, LocalPort);
3483+
EstablishConnection con =
3484+
new EstablishConnection(actual_host, actual_port, Socks_client);
34633485
//@iroqueta
3464-
sock.setTcpNoDelay(tcpNoDelay);
3465-
}
3466-
break; // success
3467-
}
3468-
catch (SocketException se)
3469-
{
3470-
if (idx == addr_list.length-1)
3471-
throw se; // we tried them all
3472-
}
3473-
}
3474-
}
3475-
}
3476-
else
3477-
{
3478-
EstablishConnection con =
3479-
new EstablishConnection(actual_host, actual_port, Socks_client);
3480-
//@iroqueta
3481-
con.setTcpNoDelay(tcpNoDelay);
3486+
con.setTcpNoDelay(tcpNoDelay);
34823487

3483-
con.start();
3484-
try
3485-
{ con.join((long) con_timeout); }
3486-
catch (InterruptedException ie)
3487-
{ }
3488+
con.start();
3489+
try
3490+
{ con.join((long) con_timeout); }
3491+
catch (InterruptedException ie)
3492+
{ }
34883493

3489-
if (con.getException() != null)
3490-
throw con.getException();
3491-
if ((sock = con.getSocket()) == null)
3492-
{
3493-
con.forget();
3494-
if ((sock = con.getSocket()) == null)
3495-
throw new InterruptedIOException("Connection establishment timed out");
3496-
}
3497-
}
3494+
if (con.getException() != null)
3495+
throw con.getException();
3496+
if ((sock = con.getSocket()) == null)
3497+
{
3498+
con.forget();
3499+
if ((sock = con.getSocket()) == null)
3500+
throw new InterruptedIOException("Connection establishment timed out");
3501+
}
3502+
}
34983503

3499-
return sock;
3504+
return sock;
3505+
}
3506+
finally
3507+
{
3508+
if (sock != null) sock.close();
3509+
}
35003510
}
35013511

35023512

common/src/main/java/HTTPClient/SocksClient.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,9 @@ Socket getSocket(String host, int port, InetAddress localAddr,
212212

213213
return sock;
214214
}
215-
catch (IOException ioe)
215+
finally
216216
{
217-
if (sock != null)
218-
{
219-
try { sock.close(); }
220-
catch (IOException ee) {}
221-
}
222-
223-
throw ioe;
217+
if (sock != null) sock.close();
224218
}
225219
}
226220

common/src/main/java/com/genexus/CommonUtil.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.math.BigInteger;
2020
import java.net.HttpURLConnection;
2121
import java.net.URL;
22+
import java.util.regex.Matcher;
23+
import java.util.regex.Pattern;
2224

2325
import com.genexus.common.interfaces.SpecificImplementation;
2426

@@ -2712,14 +2714,27 @@ public static <T> T[] concatArrays(T[] first, T[] second) {
27122714
}
27132715

27142716

2717+
private static Pattern pagingSelectPattern;
27152718
public static String pagingSelect(String select)
27162719
{
27172720
String pagingSelect = ltrim(select);
2718-
// Quita distinct
27192721
if(pagingSelect.startsWith("DISTINCT"))
27202722
pagingSelect = pagingSelect.substring(9);
2721-
// Renombra referencias a tablas por GXICTE
27222723
pagingSelect = pagingSelect.replaceAll("T\\d+\\.", "GX_ICTE.");
2724+
if(pagingSelectPattern == null)
2725+
pagingSelectPattern = Pattern.compile("GX_ICTE\\.(\\[\\w+]) AS \\b(\\w+)\\b(?=,|$)");
2726+
Matcher match = pagingSelectPattern.matcher(pagingSelect);
2727+
HashMap<String, String> maps = new HashMap<>();
2728+
while(match.find())
2729+
{
2730+
if(match.groupCount() == 2)
2731+
{
2732+
maps.put(match.group(0), String.format("GX_ICTE.[%s]", match.group(2)));
2733+
maps.put(match.group(1), String.format("[%s]", match.group(2)));
2734+
}
2735+
}
2736+
for(Map.Entry<String, String> map : maps.entrySet())
2737+
pagingSelect = pagingSelect.replace(map.getKey(), map.getValue());
27232738
return pagingSelect;
27242739
}
27252740

common/src/main/java/com/genexus/GXJarClassLoader.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ private byte[] loadBytes(String className)
170170
className = className.replace('.', '/') + ".class";
171171

172172
logger.debug("## GXJarClassLoader: Loading class: " + className + " [" + source + "]");
173+
BufferedInputStream bis = null;
174+
InputStream theStream = null;
173175
try
174176
{
175177
if(sourceIsJAR)
@@ -178,7 +180,7 @@ private byte[] loadBytes(String className)
178180
if((theEntry = zipFile.getEntry(className)) != null)
179181
{
180182
result = new byte[(int)theEntry.getSize()];
181-
InputStream theStream = zipFile.getInputStream(theEntry);
183+
theStream = zipFile.getInputStream(theEntry);
182184
new DataInputStream(new BufferedInputStream(theStream)).readFully(result);
183185
theStream.close();
184186
}
@@ -189,13 +191,21 @@ private byte[] loadBytes(String className)
189191
if(theFile.exists())
190192
{
191193
result = new byte[(int)theFile.length()];
192-
FileInputStream theStream = new FileInputStream(theFile);
194+
theStream = new FileInputStream(theFile);
193195
new DataInputStream(new BufferedInputStream(theStream)).readFully(result);
194196
theStream.close();
195197
classTimeStamps.put(className, new Long(theFile.lastModified()));
196198
}
197199
}
198200
}catch(IOException e) { ; }
201+
finally
202+
{
203+
try{
204+
if (bis != null) bis.close();
205+
if (theStream != null) theStream.close();
206+
}
207+
catch (IOException ioe) { logger.error("## GXJarClassLoader: Failed to close buffered input stream", ioe ); }
208+
}
199209
return result;
200210
}
201211

common/src/main/java/com/genexus/GXParameterPacker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ public final void writeBlobfile(String fileName)
422422

423423
if (fileName.trim().length() > 0)
424424
{
425-
try
425+
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(fileName))))
426426
{
427-
data = CommonUtil.readToByteArray(new BufferedInputStream(new FileInputStream(new File(fileName))));
427+
data = CommonUtil.readToByteArray(bis);
428428
}
429429
catch (IOException e)
430430
{

common/src/main/java/com/genexus/ImagesPath.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ private static void loadImageList(String KBId)
8989
if (is != null)
9090
{
9191
parseLocations = false;
92-
BufferedReader bufread = new BufferedReader(new InputStreamReader(is, "UTF8"));
93-
line = bufread.readLine();
94-
while (line != null)
95-
{
96-
parseLine(line, KBId);
92+
try (BufferedReader bufread = new BufferedReader(new InputStreamReader(is, "UTF8"))) {
9793
line = bufread.readLine();
94+
while (line != null) {
95+
parseLine(line, KBId);
96+
line = bufread.readLine();
97+
}
9898
}
99-
bufread.close();
10099
}
101100
}
102101
catch (UnsupportedEncodingException e)

0 commit comments

Comments
 (0)