Skip to content

Commit 5ba2807

Browse files
committed
Catch exception of historical folo record and exit
1 parent 6282169 commit 5ba2807

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/main/java/org/commonjava/util/sidecar/services/ReportService.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.commonjava.util.sidecar.services;
1717

1818
import com.fasterxml.jackson.databind.ObjectMapper;
19+
import io.quarkus.runtime.Quarkus;
1920
import io.quarkus.runtime.Startup;
2021
import io.quarkus.vertx.ConsumeEvent;
2122
import io.vertx.core.json.JsonObject;
@@ -101,6 +102,7 @@ private void loadReport( String path )
101102

102103
@ConsumeEvent( value = FOLO_BUILD )
103104
public void storeTrackedDownload( JsonObject message )
105+
throws Exception
104106
{
105107
String trackingPath = message.getString( TRACKING_PATH );
106108
String trackingId = message.getString( TRACKING_ID );
@@ -119,12 +121,31 @@ public void storeTrackedDownload( JsonObject message )
119121
return;
120122
}
121123
String originalUrl = entryDTO.getOriginUrl() == null ? "" : entryDTO.getOriginUrl();
122-
Response response = trackingService.recordArtificat( trackingId, trackingPath, storeKey.getPackageType(),
123-
storeKey.getType().name(), storeKey.getName(), originalUrl,
124-
entryDTO.getSize(), entryDTO.getMd5(), entryDTO.getSha1(),
125-
entryDTO.getSha256() );
126-
logger.debug( "Finished consuming folo record seal event for path:{}, trackingId:{}, rep code: {}, body: {}",
127-
trackingPath, trackingId, response.getStatus(), response.getStatusInfo().getReasonPhrase() );
124+
boolean exception = false;
125+
try
126+
{
127+
Response response = trackingService.recordArtificat( trackingId, trackingPath, storeKey.getPackageType(),
128+
storeKey.getType().name(), storeKey.getName(),
129+
originalUrl, entryDTO.getSize(), entryDTO.getMd5(),
130+
entryDTO.getSha1(), entryDTO.getSha256() );
131+
logger.debug(
132+
"Finished consuming folo record seal event for path:{}, trackingId:{}, rep code: {}, body: {}",
133+
trackingPath, trackingId, response.getStatus(), response.getStatusInfo().getReasonPhrase() );
134+
}
135+
catch ( Exception e )
136+
{
137+
exception = true;
138+
throw new Exception( "Sidecar failed to record folo for historical entry, will stop.", e );
139+
}
140+
finally
141+
{
142+
if ( exception )
143+
{
144+
// exit with default code -1
145+
Quarkus.asyncExit();
146+
}
147+
}
148+
128149
}
129150

130151
}

0 commit comments

Comments
 (0)