FluentLenium/FluentLenium — pull request #88 by nurkiewicz (2013-07-24 15:02:09+00:00)
Title: Avoiding Stack

Cyclic dependencies aren't generally a good idea but sometimes useful, e.g.:

```java
class MainPage extends FluentPage {

@Page private Dialog dialog;

public Dialog openDialog() { return dialog; }

public MainPage done() { return this; }

}

class Dialog extends FluentPage {

@Page private Panel panel;

@Page private MainPage mainPage;

public Panel showPanel() { return panel; }

public MainPage close() { return mainPage; }

}

class Panel extends FluentPage {

@Page private Dialog dialog;

public Dialog hide() { return dialog; }

}
```

This allows me to write readable and fluent flows:

```java
mainPage.
openDialog().
showPanel().
hide().
close().
done();
```

Unfortunately FluentLenium enters infinite recursive loop while traversing this cycle resulting in `StackOverflowError`:

at org.fluentlenium.core.FluentAdapter.injectPageIntoContainer(FluentAdapter.java:66)
at org.fluentlenium.core.FluentAdapter.injectPageIntoContainer(FluentAdapter.java:66)

This pull request attempts to fix the problem by caching already created and instrumented pages. Also some dead code was removed.