File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
cucumber-scala/src/main/scala/io/cucumber/scala Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/master/CH
13
13
14
14
### Changed
15
15
16
+ - [ Internal] Fix ` getLocation ` wherever it was wrongly defined. ([ #404 ] ( https://github.com/cucumber/cucumber-jvm-scala/issues/404 ) )
17
+
16
18
### Deprecated
17
19
18
20
### Removed
@@ -24,6 +26,7 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/master/CH
24
26
### Changed
25
27
26
28
- [ Internal] Implement ` HookDefinition.getHookType ` and unimplement ` Location.getLocation ` . No impact expected for users.
29
+ ([ #401 ] ( https://github.com/cucumber/cucumber-jvm-scala/issues/401 ) )
27
30
28
31
## [ 8.29.0] (2025-07-15)
29
32
Original file line number Diff line number Diff line change @@ -9,9 +9,25 @@ private[scala] object Utils {
9
9
val frames = Thread .currentThread().getStackTrace
10
10
val currentClass = self.getClass.getName
11
11
// Note: the -1 check is here for Scala < 2.13 and objects
12
- frames.reverse
13
- .find(f => f.getClassName == currentClass && f.getLineNumber != - 1 )
14
- .get
12
+ findLast(frames)(f =>
13
+ f.getClassName == currentClass && f.getLineNumber != - 1
14
+ ) match {
15
+ case Some (stackFrame) => stackFrame
16
+ case None =>
17
+ throw new IllegalStateException (
18
+ s " Not able to find stack frame for $currentClass"
19
+ )
20
+ }
21
+ }
22
+
23
+ // Copied from Scala 2.13 library, not available in 2.12 nor in scala-collections-compat
24
+ private def findLast [A ](seq : Array [A ])(p : A => Boolean ): Option [A ] = {
25
+ val it = seq.reverseIterator
26
+ while (it.hasNext) {
27
+ val elem = it.next()
28
+ if (p(elem)) return Some (elem)
29
+ }
30
+ None
15
31
}
16
32
17
33
}
You can’t perform that action at this time.
0 commit comments