// Use the default implementation.
};
+ private UnpackErrorHandler unpackErrorHandler = new DefaultUnpackErrorHandler();
+
/** Hook to report on the commands after execution. */
private PostReceiveHook postReceive;
postReceive = h != null ? h : PostReceiveHook.NULL;
}
+ /**
+ * @param unpackErrorHandler
+ * the unpackErrorHandler to set
+ * @since 5.7
+ */
+ public void setUnpackErrorHandler(UnpackErrorHandler unpackErrorHandler) {
+ this.unpackErrorHandler = unpackErrorHandler;
+ }
+
/**
* Set whether this class will report command failures as warning messages
* before sending the command results.
} catch (IOException | RuntimeException
| SubmoduleValidationException | Error err) {
unlockPack();
- sendStatusReport(err);
+ unpackErrorHandler.handleUnpackException(err);
throw new UnpackException(err);
}
}
filterCommands(Result.OK));
}
}
+
+ private class DefaultUnpackErrorHandler implements UnpackErrorHandler {
+ @Override
+ public void handleUnpackException(Throwable t) throws IOException {
+ sendStatusReport(t);
+ }
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2019, Google LLC and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.transport;
+
+import java.io.IOException;
+
+/**
+ * Exception handler for processing an incoming pack file.
+ *
+ * @since 5.7
+ */
+public interface UnpackErrorHandler {
+ /**
+ * Handle an exception thrown while unpacking the pack file.
+ *
+ * @param t
+ * exception thrown
+ * @throws IOException
+ * thrown when failed to write an error back to the client.
+ */
+ void handleUnpackException(Throwable t) throws IOException;
+}