Skip to content

Commit 3d9c802

Browse files
authored
Merge pull request boskworks#140 from prdoyle/gradle9
Upgrade to Gradle 9
2 parents d21e23b + 2998f24 commit 3d9c802

File tree

8 files changed

+40
-31
lines changed

8 files changed

+40
-31
lines changed

bosk-mongo/src/main/java/works/bosk/drivers/mongo/ChangeReceiver.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -126,49 +126,33 @@ private void connectionLoop() {
126126
}
127127
}
128128
} catch (UnprocessableEventException | UnexpectedEventProcessingException e) {
129-
addContextToException(e);
130-
LOGGER.warn("Unable to process MongoDB change event; reconnecting ({})", e.getMessage(), e);
131-
listener.onDisconnect(e);
129+
disconnect("Unable to process MongoDB change event", REMEDY_CONTINUE, e);
132130
// Reconnection will skip this event, so it's safe to try it right away
133131
continue;
134132
} catch (InterruptedException e) {
135-
addContextToException(e);
136-
LOGGER.warn("Interrupted while processing MongoDB change events; reconnecting", e);
137-
listener.onDisconnect(e);
133+
disconnect("Interrupted while processing MongoDB change events", REMEDY_CONTINUE, e);
138134
continue;
139135
} catch (IOException e) {
140-
addContextToException(e);
141-
LOGGER.warn("Unexpected exception while processing MongoDB change events; will wait and retry", e);
142-
listener.onDisconnect(e);
136+
disconnect("Unexpected exception while processing MongoDB change events", REMEDY_RETURN, e);
143137
return;
144138
} catch (UnrecognizedFormatException e) {
145-
addContextToException(e);
146-
LOGGER.warn("Unrecognized MongoDB database content format; will wait and retry", e);
147-
listener.onDisconnect(e);
139+
disconnect("Unrecognized MongoDB database content format", REMEDY_RETURN, e);
148140
return;
149141
} catch (UninitializedCollectionException e) {
150-
addContextToException(e);
151-
LOGGER.warn("MongoDB collection is not initialized; will wait and retry", e);
152-
listener.onDisconnect(e);
142+
disconnect("MongoDB collection is not initialized", REMEDY_RETURN, e);
153143
return;
154144
} catch (InitialRootActionException e) {
155-
addContextToException(e);
156-
LOGGER.warn("Unable to initialize bosk state; will wait and retry", e);
157-
listener.onDisconnect(e);
145+
disconnect("Unable to initialize bosk state", REMEDY_RETURN, e);
158146
return;
159147
} catch (TimeoutException e) {
160-
addContextToException(e);
161-
LOGGER.warn("Timed out waiting for bosk state to initialize; will wait and retry", e);
162-
listener.onDisconnect(e);
148+
disconnect("Timed out waiting for bosk state to initialize", REMEDY_RETURN, e);
163149
return;
164150
} catch (DisconnectedException e) {
165151
addContextToException(e);
166152
LOGGER.warn("Driver is disconnected; will wait and retry", e);
167153
return;
168154
} catch (RuntimeException | Error e) {
169-
addContextToException(e);
170-
LOGGER.warn("Unexpected exception after connecting to MongoDB; will wait and retry", e);
171-
listener.onDisconnect(e);
155+
disconnect("Unexpected exception after connecting to MongoDB", REMEDY_RETURN, e);
172156
return;
173157
}
174158
} catch (RuntimeException e) {
@@ -194,6 +178,16 @@ private void connectionLoop() {
194178
}
195179
}
196180

181+
private void disconnect(String description, String remedy, Throwable e) {
182+
addContextToException(e);
183+
if (isClosed) {
184+
LOGGER.debug("(Driver is already closed) {}", description, e);
185+
} else {
186+
LOGGER.warn("{}; {}", description, remedy, e);
187+
}
188+
listener.onDisconnect(e);
189+
}
190+
197191
private void addContextToException(Throwable x) {
198192
x.addSuppressed(creationPoint);
199193
}
@@ -275,4 +269,14 @@ private void processEvent(ChangeStreamDocument<BsonDocument> event) throws Unpro
275269

276270
private static final AtomicLong EVENT_COUNTER = new AtomicLong(0);
277271
private static final Logger LOGGER = LoggerFactory.getLogger(ChangeReceiver.class);
272+
273+
/**
274+
* Suitable for {@code continue} in {@link #connectionLoop()}
275+
*/
276+
private static final String REMEDY_CONTINUE = "reconnecting";
277+
278+
/**
279+
* Suitable for {@code return} in {@link #connectionLoop()}
280+
*/
281+
private static final String REMEDY_RETURN = "will wait and retry";
278282
}

bosk-mongo/src/main/java/works/bosk/drivers/mongo/MainDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,12 @@ public MongoStatus readStatus() throws Exception {
362362

363363
@Override
364364
public void close() {
365+
receiver.close();
366+
formatDriver.close();
365367
if (!isClosed.getAndSet(true)) {
366368
// It's important we don't call this twice, or else it will throw
367369
mongoClient.close();
368370
}
369-
receiver.close();
370-
formatDriver.close();
371371
}
372372

373373
/**

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ allprojects {
2424
group = 'works.bosk'
2525
// version should be set as a property with -Pversion
2626

27+
tasks.withType(Javadoc).configureEach {
28+
options.addStringOption('Xdoclint:-missing', '-quiet')
29+
}
2730
}
2831

2932
configure(subprojects.findAll {
@@ -56,6 +59,7 @@ configure(subprojects.findAll {
5659
options.forkOptions.jvmArgs << '--sun-misc-unsafe-memory-access=allow' // For Lombok
5760
}
5861

62+
// It's important that bosk-annotations has no deps so other projects won't hesitate to use it
5963
if (name != "bosk-annotations") {
6064
dependencies {
6165
annotationProcessor libs.lombok

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.configuration-cache=true

gradle/wrapper/gradle-wrapper.jar

59 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)