1
1
/*
2
- * Copyright 2016-2024 DiffPlug
2
+ * Copyright 2016-2025 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.
@@ -457,12 +457,11 @@ protected Integer calculateState() throws Exception {
457
457
*/
458
458
public void custom (String name , Closure <String > formatter ) {
459
459
requireNonNull (formatter , "formatter" );
460
- Closure <String > dehydrated = formatter .dehydrate ();
461
- custom (name , new ClosureFormatterFunc (dehydrated ));
460
+ custom (name , new ClosureFormatterFunc (formatter ));
462
461
}
463
462
464
463
static class ClosureFormatterFunc implements FormatterFunc , Serializable {
465
- private final Closure <String > closure ;
464
+ private Closure <String > closure ;
466
465
467
466
ClosureFormatterFunc (Closure <String > closure ) {
468
467
this .closure = closure ;
@@ -472,6 +471,14 @@ static class ClosureFormatterFunc implements FormatterFunc, Serializable {
472
471
public String apply (String unixNewlines ) {
473
472
return closure .call (unixNewlines );
474
473
}
474
+
475
+ private void writeObject (java .io .ObjectOutputStream stream ) throws java .io .IOException {
476
+ stream .writeObject (closure .dehydrate ());
477
+ }
478
+
479
+ private void readObject (java .io .ObjectInputStream stream ) throws java .io .IOException , ClassNotFoundException {
480
+ this .closure = (Closure <String >) stream .readObject ();
481
+ }
475
482
}
476
483
477
484
/**
0 commit comments