Updated documentation for GuavaEventBusHijacker and ReportingEventBus
This commit is contained in:
		| @@ -15,7 +15,7 @@ | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|   | ||||
|  | ||||
| package ru.windcorp.progressia.common.hacks; | ||||
|  | ||||
| import java.lang.reflect.Constructor; | ||||
| @@ -29,15 +29,14 @@ import com.google.common.util.concurrent.MoreExecutors; | ||||
| import ru.windcorp.progressia.common.util.crash.CrashReports; | ||||
|  | ||||
| /** | ||||
|  * This class had to be written because there is not legal way to instantiate a | ||||
|  * non-async | ||||
|  * {@link EventBus} with both a custom identifier and a custom exception | ||||
|  * handler. Which | ||||
|  * is a shame. Guava maintainers know about the issue but have rejected | ||||
|  * solutions multiple | ||||
|  * times <em>without a clearly stated reason</em>; looks like some dirty | ||||
|  * reflection will | ||||
|  * have to do. | ||||
|  * This class had to be written because there is no legal way to instantiate a | ||||
|  * non-async {@link EventBus} with both a custom identifier and a custom | ||||
|  * exception handler. Which is a shame. Guava maintainers know about the issue | ||||
|  * but have rejected solutions multiple times <em>without a clearly stated | ||||
|  * reason</em>; looks like some dirty reflection will have to do. | ||||
|  * <p> | ||||
|  * When explicitly referencing this class, please mention its usage in | ||||
|  * implementation notes because it is unreliable long-term. | ||||
|  *  | ||||
|  * @author javapony | ||||
|  */ | ||||
|   | ||||
| @@ -15,18 +15,34 @@ | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|   | ||||
|  | ||||
| package ru.windcorp.progressia.common.util.crash; | ||||
|  | ||||
| import com.google.common.eventbus.EventBus; | ||||
|  | ||||
| import ru.windcorp.progressia.common.hacks.GuavaEventBusHijacker; | ||||
|  | ||||
| /** | ||||
|  * A utility for creating Guava's {@link EventBus}es that | ||||
|  * {@linkplain CrashReports report} exceptions instead of suppressing them. | ||||
|  *  | ||||
|  * @author javapony | ||||
|  */ | ||||
| public class ReportingEventBus { | ||||
|  | ||||
| 	private ReportingEventBus() { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Instantiates a new {@link EventBus} with the provided identifier that | ||||
| 	 * reports any unhandled exceptions with {@link CrashReports}. | ||||
| 	 *  | ||||
| 	 * @param identifier the identifier of the new bus | ||||
| 	 * @return the created event bus | ||||
| 	 * @implNote This implementation relies on {@link GuavaEventBusHijacker} for | ||||
| 	 *           creating buses with custom identifiers and uncaught exception | ||||
| 	 *           handlers. It may break suddenly with a Guava update. | ||||
| 	 */ | ||||
| 	public static EventBus create(String identifier) { | ||||
| 		return GuavaEventBusHijacker.newEventBus( | ||||
| 			identifier, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user