@@ -1633,6 +1633,9 @@ public ConfigurableApplicationContext getApplicationContext() {
1633
1633
1634
1634
}
1635
1635
1636
+ /**
1637
+ * {@link SpringApplicationHook} decorator that ensures the hook is only used once.
1638
+ */
1636
1639
private static final class SingleUseSpringApplicationHook implements SpringApplicationHook {
1637
1640
1638
1641
private final AtomicBoolean used = new AtomicBoolean ();
@@ -1651,8 +1654,8 @@ public SpringApplicationRunListener getRunListener(SpringApplication springAppli
1651
1654
}
1652
1655
1653
1656
/**
1654
- * <<<<<<< HEAD Starts a non-daemon thread to keep the JVM alive on
1655
- * {@link ContextRefreshedEvent}. Stops the thread on {@link ContextClosedEvent}.
1657
+ * Starts a non-daemon thread to keep the JVM alive on {@link ContextRefreshedEvent}.
1658
+ * Stops the thread on {@link ContextClosedEvent}.
1656
1659
*/
1657
1660
private static final class KeepAlive implements ApplicationListener <ApplicationContextEvent > {
1658
1661
@@ -1696,31 +1699,34 @@ private void stopKeepAliveThread() {
1696
1699
1697
1700
}
1698
1701
1702
+ /**
1703
+ * Strategy used to handle startup concerns.
1704
+ */
1699
1705
abstract static class Startup {
1700
1706
1701
1707
private Duration timeTakenToStarted ;
1702
1708
1703
- abstract long startTime ();
1709
+ protected abstract long startTime ();
1704
1710
1705
- abstract Long processUptime ();
1711
+ protected abstract Long processUptime ();
1706
1712
1707
- abstract String action ();
1713
+ protected abstract String action ();
1708
1714
1709
1715
final Duration started () {
1710
1716
long now = System .currentTimeMillis ();
1711
1717
this .timeTakenToStarted = Duration .ofMillis (now - startTime ());
1712
1718
return this .timeTakenToStarted ;
1713
1719
}
1714
1720
1721
+ Duration timeTakenToStarted () {
1722
+ return this .timeTakenToStarted ;
1723
+ }
1724
+
1715
1725
private Duration ready () {
1716
1726
long now = System .currentTimeMillis ();
1717
1727
return Duration .ofMillis (now - startTime ());
1718
1728
}
1719
1729
1720
- Duration timeTakenToStarted () {
1721
- return this .timeTakenToStarted ;
1722
- }
1723
-
1724
1730
static Startup create () {
1725
1731
ClassLoader classLoader = Startup .class .getClassLoader ();
1726
1732
return (ClassUtils .isPresent ("jdk.crac.management.CRaCMXBean" , classLoader )
@@ -1730,61 +1736,61 @@ static Startup create() {
1730
1736
1731
1737
}
1732
1738
1733
- private static class CoordinatedRestoreAtCheckpointStartup extends Startup {
1739
+ /**
1740
+ * Standard {@link Startup} implementation.
1741
+ */
1742
+ private static class StandardStartup extends Startup {
1734
1743
1735
- private final StandardStartup fallback = new StandardStartup ();
1744
+ private final Long startTime = System . currentTimeMillis ();
1736
1745
1737
1746
@ Override
1738
- Long processUptime () {
1739
- long uptime = CRaCMXBean .getCRaCMXBean ().getUptimeSinceRestore ();
1740
- return (uptime >= 0 ) ? uptime : this .fallback .processUptime ();
1747
+ protected long startTime () {
1748
+ return this .startTime ;
1741
1749
}
1742
1750
1743
1751
@ Override
1744
- String action () {
1745
- if (restoreTime () >= 0 ) {
1746
- return "Restored" ;
1752
+ protected Long processUptime () {
1753
+ try {
1754
+ return ManagementFactory .getRuntimeMXBean ().getUptime ();
1755
+ }
1756
+ catch (Throwable ex ) {
1757
+ return null ;
1747
1758
}
1748
- return this .fallback .action ();
1749
- }
1750
-
1751
- private long restoreTime () {
1752
- return CRaCMXBean .getCRaCMXBean ().getRestoreTime ();
1753
1759
}
1754
1760
1755
1761
@ Override
1756
- long startTime () {
1757
- long restoreTime = restoreTime ();
1758
- if (restoreTime >= 0 ) {
1759
- return restoreTime ;
1760
- }
1761
- return this .fallback .startTime ();
1762
+ protected String action () {
1763
+ return "Started" ;
1762
1764
}
1763
1765
1764
1766
}
1765
1767
1766
- private static class StandardStartup extends Startup {
1768
+ /**
1769
+ * Coordinated-Restore-At-Checkpoint {@link Startup} implementation.
1770
+ */
1771
+ private static class CoordinatedRestoreAtCheckpointStartup extends Startup {
1767
1772
1768
- private final Long startTime = System . currentTimeMillis ();
1773
+ private final StandardStartup fallback = new StandardStartup ();
1769
1774
1770
1775
@ Override
1771
- long startTime () {
1772
- return this .startTime ;
1776
+ protected Long processUptime () {
1777
+ long uptime = CRaCMXBean .getCRaCMXBean ().getUptimeSinceRestore ();
1778
+ return (uptime >= 0 ) ? uptime : this .fallback .processUptime ();
1773
1779
}
1774
1780
1775
1781
@ Override
1776
- Long processUptime () {
1777
- try {
1778
- return ManagementFactory .getRuntimeMXBean ().getUptime ();
1779
- }
1780
- catch (Throwable ex ) {
1781
- return null ;
1782
- }
1782
+ protected String action () {
1783
+ return (restoreTime () >= 0 ) ? "Restored" : this .fallback .action ();
1784
+ }
1785
+
1786
+ private long restoreTime () {
1787
+ return CRaCMXBean .getCRaCMXBean ().getRestoreTime ();
1783
1788
}
1784
1789
1785
1790
@ Override
1786
- String action () {
1787
- return "Started" ;
1791
+ protected long startTime () {
1792
+ long restoreTime = restoreTime ();
1793
+ return (restoreTime >= 0 ) ? restoreTime : this .fallback .startTime ();
1788
1794
}
1789
1795
1790
1796
}
0 commit comments