Repository: appium/java-client
Issue: java -client4.1  "EventFiringWebDriverFactory.getEventFiringWebDriver"capabilities turn to null

## Description

use java-client 4.1 found :+1: 

capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, browser_Name); 
            capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, platform_Name);  
            capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,device_Name);  
            capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, platform_Version);  

```
  driver = new AndroidDriver(new URL(hubURL),capabilities);
  driver2= EventFiringWebDriverFactory.getEventFiringWebDriver(driver, new AlertListener(), new ElementListener());
```

the driver2 is null!!!!!

when i debug found when the code run into "EventFiringWebDriverFactory.getEventFiringWebDriver(driver, new AlertListener(), new ElementListener());"

the capabilities turn to null;
## Environment

jdk 1,7
java -client 4.1
selenium 2.53


Changed files:
src/main/java/io/appium/java_client/events/DefaultListener.java, src/test/java/io/appium/java_client/events/EmptyWebDriver.java, src/test/java/io/appium/java_client/events/DefaultEventListenerTest.java, src/main/java/io/appium/java_client/events/DefaultAspect.java

diff --git a/src/main/java/io/appium/java_client/events/DefaultAspect.java b/src/main/java/io/appium/java_client/events/DefaultAspect.java
index 3bec135a..652c17a8 100644
--- a/src/main/java/io/appium/java_client/events/DefaultAspect.java
+++ b/src/main/java/io/appium/java_client/events/DefaultAspect.java
@@ -156,7 +156,7 @@ class DefaultAspect {
             return null;
         }
 
-        Object result = null;
+        Object result = toBeTransformed;
         if (getClassForProxy(toBeTransformed.getClass()) != null) {
             result = context.getBean(DefaultBeanConfiguration.COMPONENT_BEAN, toBeTransformed);
         }
diff --git a/src/main/java/io/appium/java_client/events/DefaultListener.java b/src/main/java/io/appium/java_client/events/DefaultListener.java
index e665ad5e..e33b11eb 100644
--- a/src/main/java/io/appium/java_client/events/DefaultListener.java
+++ b/src/main/java/io/appium/java_client/events/DefaultListener.java
@@ -42,7 +42,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-public class DefaultListener implements Listener, AppiumWebDriverEventListener, ListensToException,
+class DefaultListener implements Listener, AppiumWebDriverEventListener, ListensToException,
     SearchingEventListener, NavigationEventListener,
     JavaScriptEventListener, ElementEventListener, AlertEventListener,
     WindowEventListener, ContextEventListener, RotationEventListener {
diff --git a/src/test/java/io/appium/java_client/events/DefaultEventListenerTest.java b/src/test/java/io/appium/java_client/events/DefaultEventListenerTest.java
index 084b5918..a2dfc33a 100644
--- a/src/test/java/io/appium/java_client/events/DefaultEventListenerTest.java
+++ b/src/test/java/io/appium/java_client/events/DefaultEventListenerTest.java
@@ -1,6 +1,8 @@
 package io.appium.java_client.events;
 
 import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 
 import io.appium.java_client.events.listeners.AlertListener;
@@ -18,6 +20,7 @@ import org.junit.BeforeClass;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
+import org.openqa.selenium.Capabilities;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class DefaultEventListenerTest extends BaseListenerTest {
@@ -88,4 +91,11 @@ public class DefaultEventListenerTest extends BaseListenerTest {
         assertThat(super.assertThatWindowListenerWorks(driver, SingleListeners
             .listeners.get(WindowListener.class), StringUtils.EMPTY), is(true));
     }
+
+    @Test
+    public void whenNonListenableObjectIsReturned() {
+        Capabilities capabilities = driver.getCapabilities();
+        assertNotNull(capabilities);
+        assertEquals(capabilities.asMap().size(), 2);
+    }
 }
diff --git a/src/test/java/io/appium/java_client/events/EmptyWebDriver.java b/src/test/java/io/appium/java_client/events/EmptyWebDriver.java
index b3763040..64e7c8f9 100644
--- a/src/test/java/io/appium/java_client/events/EmptyWebDriver.java
+++ b/src/test/java/io/appium/java_client/events/EmptyWebDriver.java
@@ -10,7 +10,9 @@ import org.apache.commons.lang3.StringUtils;
 import org.openqa.selenium.Alert;
 import org.openqa.selenium.By;
 import org.openqa.selenium.ContextAware;
+import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.Cookie;
+import org.openqa.selenium.HasCapabilities;
 import org.openqa.selenium.JavascriptExecutor;
 import org.openqa.selenium.Rotatable;
 import org.openqa.selenium.ScreenOrientation;
@@ -24,15 +26,18 @@ import org.openqa.selenium.internal.FindsByLinkText;
 import org.openqa.selenium.internal.FindsByTagName;
 import org.openqa.selenium.internal.FindsByXPath;
 import org.openqa.selenium.logging.Logs;
+import org.openqa.selenium.remote.DesiredCapabilities;
 
 import java.net.URL;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 public class EmptyWebDriver implements WebDriver, ContextAware, Rotatable, FindsByClassName,
     FindsByCssSelector, FindsById, FindsByLinkText, FindsByTagName, FindsByXPath,
     FindsByAccessibilityId<StubWebElement>, FindsByAndroidUIAutomator<StubWebElement>,
-    FindsByIosUIAutomation<StubWebElement>, JavascriptExecutor {
+    FindsByIosUIAutomation<StubWebElement>, JavascriptExecutor, HasCapabilities {
 
     private static List<StubWebElement> createStubList() {
         return ImmutableList.of(new StubWebElement(), new StubWebElement());
@@ -198,6 +203,13 @@ public class EmptyWebDriver implements WebDriver, ContextAware, Rotatable, Finds
         return null;
     }
 
+    @Override public Capabilities getCapabilities() {
+        Map<String, Object> map = new HashMap<>();
+        map.put("0",StringUtils.EMPTY);
+        map.put("1",StringUtils.EMPTY);
+        return new DesiredCapabilities(map);
+    }
+
     private class StubTargetLocator implements TargetLocator {
 
         private final WebDriver driver;