From 2925f1b86a9cc8119911e04b3e6b56f034726468 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 28 Jul 2017 07:31:32 +0100 Subject: [PATCH] Polish "Simplify retrieval of Narayana XARecoveryModule" Closes gh-9725 --- .../narayana/NarayanaRecoveryManagerBean.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaRecoveryManagerBean.java b/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaRecoveryManagerBean.java index 58be823528..25f6ed1635 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaRecoveryManagerBean.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaRecoveryManagerBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,17 +51,19 @@ public class NarayanaRecoveryManagerBean implements InitializingBean, Disposable this.recoveryManagerService.destroy(); } - void registerXAResourceRecoveryHelper(XAResourceRecoveryHelper xaResourceRecoveryHelper) { + void registerXAResourceRecoveryHelper( + XAResourceRecoveryHelper xaResourceRecoveryHelper) { getXARecoveryModule().addXAResourceRecoveryHelper(xaResourceRecoveryHelper); } private XARecoveryModule getXARecoveryModule() { - XARecoveryModule xaRecoveryModule = XARecoveryModule.getRegisteredXARecoveryModule(); - if (xaRecoveryModule == null) { - throw new IllegalStateException( - "XARecoveryModule is not registered with recovery manager"); + XARecoveryModule xaRecoveryModule = XARecoveryModule + .getRegisteredXARecoveryModule(); + if (xaRecoveryModule != null) { + return xaRecoveryModule; } - return xaRecoveryModule; + throw new IllegalStateException( + "XARecoveryModule is not registered with recovery manager"); } }