Skip to content

Commit

Permalink
Fix indentation, fix a weird issue with Jetty + toString
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Apr 2, 2012
1 parent 38c330c commit fee0957
Showing 1 changed file with 46 additions and 34 deletions.
80 changes: 46 additions & 34 deletions modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class AtmosphereRequest implements HttpServletRequest {
private AtmosphereRequest(Builder b) {
session = b.request == null ?
new FakeHttpSession("", null, System.currentTimeMillis(), -1) :
b.session != null ? b.session : b.request.getSession();
b.session != null ? b.session : b.request.getSession();

if (b.inputStream == null) {
if (b.dataBytes != null) {
Expand Down Expand Up @@ -188,23 +188,23 @@ public DispatcherType getDispatcherType() {
*/
@Override
public String getServletPath() {
return b.servletPath != "" ? b.servletPath : (isNotNoOps()? b.request.getServletPath() : "");
return b.servletPath != "" ? b.servletPath : (isNotNoOps() ? b.request.getServletPath() : "");
}

/**
* {@inheritDoc}
*/
@Override
public String getRequestURI() {
return b.requestURI != null ? b.requestURI : (isNotNoOps()? b.request.getRequestURI() : null);
return b.requestURI != null ? b.requestURI : (isNotNoOps() ? b.request.getRequestURI() : null);
}

/**
* {@inheritDoc}
*/
@Override
public StringBuffer getRequestURL() {
return b.requestURL != null ? new StringBuffer(b.requestURL) : (isNotNoOps()? b.request.getRequestURL() : null);
return b.requestURL != null ? new StringBuffer(b.requestURL) : (isNotNoOps() ? b.request.getRequestURL() : null);
}

/**
Expand Down Expand Up @@ -288,7 +288,7 @@ public String getAuthType() {
*/
@Override
public String getContextPath() {
return isNotNoOps() && b.request.getContextPath() != null ? b.request.getContextPath() : b.contextPath != null ? b.contextPath : "";
return isNotNoOps() && b.request.getContextPath() != null ? b.request.getContextPath() : b.contextPath != null ? b.contextPath : "";
}

/**
Expand Down Expand Up @@ -364,7 +364,7 @@ public String getParameter(String s) {
public Map<String, String[]> getParameterMap() {
if (!queryComputed) {
queryComputed = true;
Map<String, String[]> m = (isNotNoOps()? b.request.getParameterMap() : Collections.<String, String[]>emptyMap());
Map<String, String[]> m = (isNotNoOps() ? b.request.getParameterMap() : Collections.<String, String[]>emptyMap());
for (String e : m.keySet()) {
b.queryStrings.put(e, getParameterValues(e));
}
Expand Down Expand Up @@ -414,15 +414,15 @@ public String getProtocol() {
*/
@Override
public ServletInputStream getInputStream() throws IOException {
return bis == null ? (isNotNoOps()? b.request.getInputStream() : null) : bis;
return bis == null ? (isNotNoOps() ? b.request.getInputStream() : null) : bis;
}

/**
* {@inheritDoc}
*/
@Override
public BufferedReader getReader() throws IOException {
return br == null ? (isNotNoOps()? b.request.getReader() : null) : br;
return br == null ? (isNotNoOps() ? b.request.getReader() : null) : br;
}

/**
Expand Down Expand Up @@ -533,7 +533,7 @@ public AsyncContext getAsyncContext() {
*/
@Override
public Object getAttribute(String s) {
return b.localAttributes.get(s) != null ? b.localAttributes.get(s) : (isNotNoOps()? b.request.getAttribute(s) : null);
return b.localAttributes.get(s) != null ? b.localAttributes.get(s) : (isNotNoOps() ? b.request.getAttribute(s) : null);
}

/**
Expand Down Expand Up @@ -641,23 +641,23 @@ public void logout() throws ServletException {
*/
@Override
public String getRemoteAddr() {
return isNotNoOps()? b.request.getRemoteAddr() : b.remoteAddr;
return isNotNoOps() ? b.request.getRemoteAddr() : b.remoteAddr;
}

/**
* {@inheritDoc}
*/
@Override
public String getRemoteHost() {
return isNotNoOps()? b.request.getRemoteHost() : b.remoteHost;
return isNotNoOps() ? b.request.getRemoteHost() : b.remoteHost;
}

/**
* {@inheritDoc}
*/
@Override
public int getRemotePort() {
return isNotNoOps()? b.request.getRemotePort() : b.remotePort;
return isNotNoOps() ? b.request.getRemotePort() : b.remotePort;
}

/**
Expand Down Expand Up @@ -729,26 +729,26 @@ public boolean isSecure() {
*/
@Override
public String getLocalName() {
return isNotNoOps()? b.request.getLocalName() : b.localName;
return isNotNoOps() ? b.request.getLocalName() : b.localName;
}

/**
* {@inheritDoc}
*/
@Override
public int getLocalPort() {
return isNotNoOps()? b.request.getLocalPort() : b.localPort;
return isNotNoOps() ? b.request.getLocalPort() : b.localPort;
}

/**
* {@inheritDoc}
*/
@Override
public String getLocalAddr() {
return isNotNoOps()? b.request.getLocalAddr() : b.localAddr;
return isNotNoOps() ? b.request.getLocalAddr() : b.localAddr;
}

private boolean isNotNoOps(){
private boolean isNotNoOps() {
return !NoOpsRequest.class.isAssignableFrom(b.request.getClass());
}

Expand Down Expand Up @@ -792,7 +792,7 @@ public boolean isDestroyable() {
public Enumeration<String> getAttributeNames() {
Set<String> l = new HashSet();
l.addAll(b.localAttributes.keySet());
Enumeration<String> e = (isNotNoOps()? b.request.getAttributeNames() : null);
Enumeration<String> e = (isNotNoOps() ? b.request.getAttributeNames() : null);
if (e != null) {
while (e.hasMoreElements()) {
l.add(e.nextElement());
Expand Down Expand Up @@ -1422,15 +1422,15 @@ public final static AtmosphereRequest loadInMemory(HttpServletRequest request) {
}

b.servletPath(request.getServletPath())
.pathInfo(request.getPathInfo())
.contextPath(request.getContextPath())
.requestURI(request.getRequestURI())
.requestURL(request.getRequestURL().toString())
.method(request.getMethod())
.serverName(request.getServerName())
.serverPort(request.getServerPort())
.destroyable(false)
.session(new FakeHttpSession(request.getSession(true)));
.pathInfo(request.getPathInfo())
.contextPath(request.getContextPath())
.requestURI(request.getRequestURI())
.requestURL(request.getRequestURL().toString())
.method(request.getMethod())
.serverName(request.getServerName())
.serverPort(request.getServerPort())
.destroyable(false)
.session(new FakeHttpSession(request.getSession(true)));

Enumeration<String> e = request.getHeaderNames();
String s;
Expand Down Expand Up @@ -1480,13 +1480,25 @@ public int hashCode() {

@Override
public String toString() {
return "AtmosphereRequest{" +
" contextPath=" + getContextPath() +
" servletPath=" + getServletPath() +
" pathInfo=" + getPathInfo() +
" requestURI=" + getRequestURI() +
" requestURL=" + getRequestURL() +
" destroyable=" + b.destroyable +
'}';
try {
return "AtmosphereRequest{" +
" contextPath=" + getContextPath() +
" servletPath=" + getServletPath() +
" pathInfo=" + getPathInfo() +
" requestURI=" + getRequestURI() +
" requestURL=" + getRequestURL() +
" destroyable=" + b.destroyable +
'}';
} catch (Exception e) {
// Jetty error
return "AtmosphereRequest{" +
" contextPath=" + getContextPath() +
" servletPath=" + getServletPath() +
" pathInfo=" + getPathInfo() +
" requestURI=" + getRequestURI() +
" destroyable=" + b.destroyable +
'}';

}
}
}

0 comments on commit fee0957

Please sign in to comment.