File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
lib/src/main/java/com/diffplug/spotless Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2016-2020 DiffPlug
2
+ * Copyright 2016-2022 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ abstract class FormatterStepImpl<State extends Serializable> extends Strict<Stat
39
39
final transient String name ;
40
40
41
41
/** Transient because only the state matters. */
42
- final transient ThrowingEx .Supplier <State > stateSupplier ;
42
+ transient ThrowingEx .Supplier <State > stateSupplier ;
43
43
44
44
FormatterStepImpl (String name , ThrowingEx .Supplier <State > stateSupplier ) {
45
45
this .name = Objects .requireNonNull (name );
@@ -53,7 +53,11 @@ public String getName() {
53
53
54
54
@ Override
55
55
protected State calculateState () throws Exception {
56
- return stateSupplier .get ();
56
+ // LazyForwardingEquality guarantees that this will only be called once, and keeping toFormat
57
+ // causes a memory leak, see https://github.com/diffplug/spotless/issues/1194
58
+ State state = stateSupplier .get ();
59
+ stateSupplier = null ;
60
+ return state ;
57
61
}
58
62
59
63
static final class Standard <State extends Serializable > extends FormatterStepImpl <State > {
You can’t perform that action at this time.
0 commit comments