Add missing synchronization and remove unnecessary volatile

This commit is contained in:
Moritz Halbritter
2023-08-02 14:51:46 +02:00
parent 497bbf9c2d
commit 3515196c2b

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
*/
public class DeferredLog implements Log {
private volatile Log destination;
private Log destination;
private final Supplier<Log> destinationSupplier;
@@ -175,7 +175,9 @@ public class DeferredLog implements Log {
}
void switchOver() {
this.destination = this.destinationSupplier.get();
synchronized (this.lines) {
this.destination = this.destinationSupplier.get();
}
}
/**