You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2025/03/17 11:36:56 UTC
(jackrabbit-oak) branch OAK-11546 created (now 855e1c7331)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch OAK-11546
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 855e1c7331 Revert "OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends"
This branch includes the following new commits:
new b40703a655 OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends
new 855e1c7331 Revert "OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends"
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 02/02: Revert "OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends"
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-11546
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 855e1c7331d05ac2903ea9ab53f3a91513e6f815
Author: Julian Reschke <re...@apache.org>
AuthorDate: Mon Mar 17 12:36:31 2025 +0100
Revert "OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends"
This reverts commit b40703a655c98f377d7fab90ab6250c93d4817b2.
---
.../apache/jackrabbit/oak/commons/pio/Closer.java | 252 ++++++++++-----------
1 file changed, 126 insertions(+), 126 deletions(-)
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
old mode 100644
new mode 100755
index ea753bd72d..54705d5a3e
--- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
@@ -1,126 +1,126 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.jackrabbit.oak.commons.pio;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.Objects;
-
-/**
- * Convenience utility to close a list of {@link Closeable}s in reverse order,
- * suppressing all but the first exception to occur.
- * <p>
- * Inspired by and replacing Guava's Closer.
- */
-public class Closer implements Closeable {
-
- private Closer() {
- // no instances for you
- }
-
- // stack of closeables to close, in general will be few
- private final Deque<Closeable> closeables = new ArrayDeque<>(3);
-
- // flag set by rethrow method
- private boolean suppressExceptionsOnClose = false;
-
- /**
- * Create instance of Closer.
- */
- public static Closer create() {
- return new Closer();
- }
-
- /**
- * Add a {@link Closeable} to the list.
- * @param closeable {@link Closeable} object to be added
- * @return the closeable param
- */
- public @Nullable <C extends Closeable> C register(@Nullable C closeable) {
- if (closeable != null) {
- closeables.add(closeable);
- }
- return closeable;
- }
-
- /**
- * Closes the set of {@link Closeable}s in reverse order.
- * <p>
- * Swallows all exceptions except the first that
- * was thrown.
- * <p>
- * If {@link #rethrow} was called before, even the first
- * exception will be suppressed.
- */
- public void close() throws IOException {
- // keep track of the IOException to throw
- Throwable toThrow = null;
-
- // close all in reverse order
- while (!closeables.isEmpty()) {
- Closeable closeable = closeables.removeLast();
- try {
- closeable.close();
- } catch (Throwable exception) {
- // remember the first one that occurred
- if (toThrow == null) {
- toThrow = exception;
- }
- }
- }
-
- // exceptions are suppressed when retrow was called
- if (!suppressExceptionsOnClose && toThrow != null) {
- // due to the contract of Closeable, the exception is either
- // a checked IOException or an unchecked exception
- if (toThrow instanceof IOException) {
- throw (IOException) toThrow;
- } else {
- throw (RuntimeException) toThrow;
- }
- }
- }
-
- /**
- * Sets a flag indicating that this method was called, then rethrows the
- * given exception (potentially wrapped into {@link Error} or {@link RuntimeException}).
- * <p>
- * {@link #close()} will not throw when this method was called before.
- * @return never returns
- * @throws IOException wrapping the input, when needed
- */
- public RuntimeException rethrow(@NotNull Throwable throwable) throws IOException {
- Objects.requireNonNull(throwable);
- suppressExceptionsOnClose = true;
- if (throwable instanceof IOException) {
- throw (IOException) throwable;
- } else if (throwable instanceof RuntimeException) {
- throw (RuntimeException) throwable;
- } else if (throwable instanceof Error) {
- throw (Error) throwable;
- } else {
- throw new RuntimeException(throwable);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.pio;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.Objects;
+
+/**
+ * Convenience utility to close a list of {@link Closeable}s in reverse order,
+ * suppressing all but the first exception to occur.
+ * <p>
+ * Inspired by and replacing Guava's Closer.
+ */
+public class Closer implements Closeable {
+
+ private Closer() {
+ // no instances for you
+ }
+
+ // stack of closeables to close, in general will be few
+ private final Deque<Closeable> closeables = new ArrayDeque<>(3);
+
+ // flag set by rethrow method
+ private boolean suppressExceptionsOnClose = false;
+
+ /**
+ * Create instance of Closer.
+ */
+ public static Closer create() {
+ return new Closer();
+ }
+
+ /**
+ * Add a {@link Closeable} to the list.
+ * @param closeable {@link Closeable} object to be added
+ * @return the closeable param
+ */
+ public @Nullable <C extends Closeable> C register(@Nullable C closeable) {
+ if (closeable != null) {
+ closeables.add(closeable);
+ }
+ return closeable;
+ }
+
+ /**
+ * Closes the set of {@link Closeable}s in reverse order.
+ * <p>
+ * Swallows all exceptions except the first that
+ * was thrown.
+ * <p>
+ * If {@link #rethrow} was called before, even the first
+ * exception will be suppressed.
+ */
+ public void close() throws IOException {
+ // keep track of the IOException to throw
+ Throwable toThrow = null;
+
+ // close all in reverse order
+ while (!closeables.isEmpty()) {
+ Closeable closeable = closeables.removeLast();
+ try {
+ closeable.close();
+ } catch (Throwable exception) {
+ // remember the first one that occurred
+ if (toThrow == null) {
+ toThrow = exception;
+ }
+ }
+ }
+
+ // exceptions are suppressed when retrow was called
+ if (!suppressExceptionsOnClose && toThrow != null) {
+ // due to the contract of Closeable, the exception is either
+ // a checked IOException or an unchecked exception
+ if (toThrow instanceof IOException) {
+ throw (IOException) toThrow;
+ } else {
+ throw (RuntimeException) toThrow;
+ }
+ }
+ }
+
+ /**
+ * Sets a flag indicating that this method was called, then rethrows the
+ * given exception (potentially wrapped into {@link Error} or {@link RuntimeException}).
+ * <p>
+ * {@link #close()} will not throw when this method was called before.
+ * @return never returns
+ * @throws IOException wrapping the input, when needed
+ */
+ public RuntimeException rethrow(@NotNull Throwable throwable) throws IOException {
+ Objects.requireNonNull(throwable);
+ suppressExceptionsOnClose = true;
+ if (throwable instanceof IOException) {
+ throw (IOException) throwable;
+ } else if (throwable instanceof RuntimeException) {
+ throw (RuntimeException) throwable;
+ } else if (throwable instanceof Error) {
+ throw (Error) throwable;
+ } else {
+ throw new RuntimeException(throwable);
+ }
+ }
+}
(jackrabbit-oak) 01/02: OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-11546
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit b40703a655c98f377d7fab90ab6250c93d4817b2
Author: Julian Reschke <re...@apache.org>
AuthorDate: Mon Mar 17 12:36:02 2025 +0100
OAK-11571: commons: add Closer class (similar to Guava Closer) - fix line ends
---
.../apache/jackrabbit/oak/commons/pio/Closer.java | 252 ++++++++++-----------
1 file changed, 126 insertions(+), 126 deletions(-)
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
old mode 100755
new mode 100644
index 54705d5a3e..ea753bd72d
--- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
@@ -1,126 +1,126 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.jackrabbit.oak.commons.pio;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.Objects;
-
-/**
- * Convenience utility to close a list of {@link Closeable}s in reverse order,
- * suppressing all but the first exception to occur.
- * <p>
- * Inspired by and replacing Guava's Closer.
- */
-public class Closer implements Closeable {
-
- private Closer() {
- // no instances for you
- }
-
- // stack of closeables to close, in general will be few
- private final Deque<Closeable> closeables = new ArrayDeque<>(3);
-
- // flag set by rethrow method
- private boolean suppressExceptionsOnClose = false;
-
- /**
- * Create instance of Closer.
- */
- public static Closer create() {
- return new Closer();
- }
-
- /**
- * Add a {@link Closeable} to the list.
- * @param closeable {@link Closeable} object to be added
- * @return the closeable param
- */
- public @Nullable <C extends Closeable> C register(@Nullable C closeable) {
- if (closeable != null) {
- closeables.add(closeable);
- }
- return closeable;
- }
-
- /**
- * Closes the set of {@link Closeable}s in reverse order.
- * <p>
- * Swallows all exceptions except the first that
- * was thrown.
- * <p>
- * If {@link #rethrow} was called before, even the first
- * exception will be suppressed.
- */
- public void close() throws IOException {
- // keep track of the IOException to throw
- Throwable toThrow = null;
-
- // close all in reverse order
- while (!closeables.isEmpty()) {
- Closeable closeable = closeables.removeLast();
- try {
- closeable.close();
- } catch (Throwable exception) {
- // remember the first one that occurred
- if (toThrow == null) {
- toThrow = exception;
- }
- }
- }
-
- // exceptions are suppressed when retrow was called
- if (!suppressExceptionsOnClose && toThrow != null) {
- // due to the contract of Closeable, the exception is either
- // a checked IOException or an unchecked exception
- if (toThrow instanceof IOException) {
- throw (IOException) toThrow;
- } else {
- throw (RuntimeException) toThrow;
- }
- }
- }
-
- /**
- * Sets a flag indicating that this method was called, then rethrows the
- * given exception (potentially wrapped into {@link Error} or {@link RuntimeException}).
- * <p>
- * {@link #close()} will not throw when this method was called before.
- * @return never returns
- * @throws IOException wrapping the input, when needed
- */
- public RuntimeException rethrow(@NotNull Throwable throwable) throws IOException {
- Objects.requireNonNull(throwable);
- suppressExceptionsOnClose = true;
- if (throwable instanceof IOException) {
- throw (IOException) throwable;
- } else if (throwable instanceof RuntimeException) {
- throw (RuntimeException) throwable;
- } else if (throwable instanceof Error) {
- throw (Error) throwable;
- } else {
- throw new RuntimeException(throwable);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.pio;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.Objects;
+
+/**
+ * Convenience utility to close a list of {@link Closeable}s in reverse order,
+ * suppressing all but the first exception to occur.
+ * <p>
+ * Inspired by and replacing Guava's Closer.
+ */
+public class Closer implements Closeable {
+
+ private Closer() {
+ // no instances for you
+ }
+
+ // stack of closeables to close, in general will be few
+ private final Deque<Closeable> closeables = new ArrayDeque<>(3);
+
+ // flag set by rethrow method
+ private boolean suppressExceptionsOnClose = false;
+
+ /**
+ * Create instance of Closer.
+ */
+ public static Closer create() {
+ return new Closer();
+ }
+
+ /**
+ * Add a {@link Closeable} to the list.
+ * @param closeable {@link Closeable} object to be added
+ * @return the closeable param
+ */
+ public @Nullable <C extends Closeable> C register(@Nullable C closeable) {
+ if (closeable != null) {
+ closeables.add(closeable);
+ }
+ return closeable;
+ }
+
+ /**
+ * Closes the set of {@link Closeable}s in reverse order.
+ * <p>
+ * Swallows all exceptions except the first that
+ * was thrown.
+ * <p>
+ * If {@link #rethrow} was called before, even the first
+ * exception will be suppressed.
+ */
+ public void close() throws IOException {
+ // keep track of the IOException to throw
+ Throwable toThrow = null;
+
+ // close all in reverse order
+ while (!closeables.isEmpty()) {
+ Closeable closeable = closeables.removeLast();
+ try {
+ closeable.close();
+ } catch (Throwable exception) {
+ // remember the first one that occurred
+ if (toThrow == null) {
+ toThrow = exception;
+ }
+ }
+ }
+
+ // exceptions are suppressed when retrow was called
+ if (!suppressExceptionsOnClose && toThrow != null) {
+ // due to the contract of Closeable, the exception is either
+ // a checked IOException or an unchecked exception
+ if (toThrow instanceof IOException) {
+ throw (IOException) toThrow;
+ } else {
+ throw (RuntimeException) toThrow;
+ }
+ }
+ }
+
+ /**
+ * Sets a flag indicating that this method was called, then rethrows the
+ * given exception (potentially wrapped into {@link Error} or {@link RuntimeException}).
+ * <p>
+ * {@link #close()} will not throw when this method was called before.
+ * @return never returns
+ * @throws IOException wrapping the input, when needed
+ */
+ public RuntimeException rethrow(@NotNull Throwable throwable) throws IOException {
+ Objects.requireNonNull(throwable);
+ suppressExceptionsOnClose = true;
+ if (throwable instanceof IOException) {
+ throw (IOException) throwable;
+ } else if (throwable instanceof RuntimeException) {
+ throw (RuntimeException) throwable;
+ } else if (throwable instanceof Error) {
+ throw (Error) throwable;
+ } else {
+ throw new RuntimeException(throwable);
+ }
+ }
+}