Skip to content

Commit 117030a

Browse files
committed
82427: Possible Performance issue with IRUS patch for DSpace 6
1 parent 76a8d77 commit 117030a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

dspace/modules/atmire-statistics-exporter/atmire-statistics-exporter-api/src/main/java/com/atmire/statistics/export/ExportUsageEventListener.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@
4242
import java.util.Date;
4343
import java.util.List;
4444
import java.util.UUID;
45+
import java.util.concurrent.TimeUnit;
4546
import javax.servlet.http.HttpServletRequest;
4647

4748
import com.atmire.statistics.export.factory.OpenURLTrackerLoggerServiceFactory;
4849
import com.atmire.statistics.export.service.OpenURLTrackerLoggerService;
4950
import org.apache.commons.lang.StringUtils;
51+
import org.apache.http.HttpResponse;
52+
import org.apache.http.client.HttpClient;
53+
import org.apache.http.client.methods.HttpGet;
54+
import org.apache.http.impl.client.HttpClientBuilder;
5055
import org.apache.log4j.Logger;
5156
import org.dspace.app.util.Util;
5257
import org.dspace.content.Bitstream;
@@ -332,19 +337,17 @@ private String getItemInfo(final Item item) {
332337
private static void processUrl(Context c, String urlStr) throws IOException, SQLException {
333338
log.debug("Prepared to send url to tracker URL: " + urlStr);
334339
System.out.println(urlStr);
335-
URLConnection conn;
336340

337341
try {
338342
// Send data
339-
URL url = new URL(urlStr);
340-
conn = url.openConnection();
343+
HttpGet httpGet = new HttpGet(urlStr);
344+
HttpClient httpClient = HttpClientBuilder.create().setConnectionTimeToLive(10, TimeUnit.SECONDS).build();
341345

342346
// Get the response
343-
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
344-
while (rd.readLine() != null) ;
347+
HttpResponse httpResponse = httpClient.execute(httpGet);
345348

346-
rd.close();
347-
if (((HttpURLConnection) conn).getResponseCode() != 200) {
349+
350+
if (httpResponse.getStatusLine().getStatusCode() != 200) {
348351
ExportUsageEventListener.logfailed(c, urlStr);
349352
} else if (log.isDebugEnabled()) {
350353
log.debug("Successfully posted " + urlStr + " on " + new Date());
@@ -357,14 +360,12 @@ private static void processUrl(Context c, String urlStr) throws IOException, SQL
357360

358361
private static void tryReprocessFailed(Context context, OpenURLTracker tracker) throws SQLException {
359362
boolean success = false;
360-
URLConnection conn;
361363
try {
362-
URL url = new URL(tracker.getUrl());
363-
conn = url.openConnection();
364-
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
365-
while (rd.readLine() != null) ;
366-
rd.close();
367-
if (((HttpURLConnection) conn).getResponseCode() == 200) {
364+
HttpGet httpGet = new HttpGet(tracker.getUrl());
365+
HttpClient httpClient = HttpClientBuilder.create().setConnectionTimeToLive(10, TimeUnit.SECONDS).build();
366+
HttpResponse httpResponse = httpClient.execute(httpGet);
367+
368+
if (httpResponse.getStatusLine().getStatusCode() == 200) {
368369
success = true;
369370
}
370371
} catch (Exception e) {

0 commit comments

Comments
 (0)