Skip to content

Commit

Permalink
LDEV-4782 - init log before loading cache regions and do never log to…
Browse files Browse the repository at this point in the history
… the console
  • Loading branch information
michaeloffner committed Jan 24, 2024
1 parent ca26217 commit 257e854
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Nov 22 15:37:52 CET 2023
build.number=14
#Wed Jan 24 14:57:19 CET 2024
build.number=15
15 changes: 9 additions & 6 deletions source/java/src/org/lucee/extension/resource/s3/S3.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ private S3(S3Cache cache, String accessKeyId, String secretAccessKey, String hos
}
}

this.log = getLog(config);
if (cacheRegions) {
new CacheRegions().start();
new CacheRegions(this.log).start();
}
this.log = getLog(config);
}

public String getHost() {
Expand Down Expand Up @@ -327,7 +327,6 @@ private String extractExpectedRegion(String msg, AmazonServiceException ase) {
}
catch (S3Exception e) {
if (log != null) log.error("s3", e);
else e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -1210,7 +1209,6 @@ public S3Info get(String bucketName, final String objectName) throws S3Exception
if ("NoSuchBucket".equals(ase.getErrorCode()) || "404".equals(ase.getStatusCode())) return null;
}
if (log != null) log.error("s3", e);
else e.printStackTrace();
}

/* Recursively delete all the objects inside given bucket */
Expand Down Expand Up @@ -2354,7 +2352,7 @@ public Region getBucketRegion(String bucketName, boolean loadIfNecessary) throws
return null;
}
if (log != null) log.error("s3", "failed to load region", ase);
else ase.printStackTrace();

// could be AccessDenied
cache.bucketRegions.put(bucketName, RegionFactory.ERROR);
return null;
Expand Down Expand Up @@ -2775,6 +2773,12 @@ public String toString() {

private class CacheRegions extends Thread {

private Log log;

public CacheRegions(Log log) {
this.log = log;
}

@Override
public void run() {
AmazonS3Client client = null;
Expand All @@ -2801,7 +2805,6 @@ public void run() {
catch (S3Exception e1) {
if (!"AccessDenied".equalsIgnoreCase(e1.getErrorCode())) { // in case we can not the region because of access right, we don't care.
if (log != null) log.log(Log.LEVEL_DEBUG, "s3", e1);
else e1.printStackTrace();
}
}
catch (Exception e) {
Expand Down

0 comments on commit 257e854

Please sign in to comment.