|
1 | 1 | /* |
2 | | - * Copyright 2005-2010 the original author or authors. |
| 2 | + * Copyright 2002-2012 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -188,7 +188,7 @@ public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws I |
188 | 188 | // "start-info", so let's try and do something about it |
189 | 189 | String contentType = StringUtils |
190 | 190 | .arrayToCommaDelimitedString(mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE)); |
191 | | - if (contentType.indexOf("startinfo") != -1) { |
| 191 | + if (contentType.contains("startinfo")) { |
192 | 192 | contentType = contentType.replace("startinfo", "start-info"); |
193 | 193 | mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); |
194 | 194 | try { |
@@ -231,16 +231,21 @@ private MimeHeaders parseMimeHeaders(InputStream inputStream) throws IOException |
231 | 231 | */ |
232 | 232 | private InputStream checkForUtf8ByteOrderMark(InputStream inputStream) throws IOException { |
233 | 233 | PushbackInputStream pushbackInputStream = new PushbackInputStream(new BufferedInputStream(inputStream), 3); |
234 | | - byte[] bom = new byte[3]; |
235 | | - if (pushbackInputStream.read(bom) != -1) { |
| 234 | + byte[] bytes = new byte[3]; |
| 235 | + int bytesRead = pushbackInputStream.read(bytes); |
| 236 | + if (bytesRead != -1) { |
236 | 237 | // check for the UTF-8 BOM, and remove it if there. See SWS-393 |
237 | | - if (!(bom[0] == (byte) 0xEF && bom[1] == (byte) 0xBB && bom[2] == (byte) 0xBF)) { |
238 | | - pushbackInputStream.unread(bom); |
| 238 | + if (!isByteOrderMark(bytes)) { |
| 239 | + pushbackInputStream.unread(bytes, 0, bytesRead); |
239 | 240 | } |
240 | 241 | } |
241 | 242 | return pushbackInputStream; |
242 | 243 | } |
243 | 244 |
|
| 245 | + private boolean isByteOrderMark(byte[] bytes) { |
| 246 | + return bytes.length == 3 && bytes[0] == (byte) 0xEF && bytes[1] == (byte) 0xBB && bytes[2] == (byte) 0xBF; |
| 247 | + } |
| 248 | + |
244 | 249 | /** |
245 | 250 | * Template method that allows for post-processing of the given {@link SOAPMessage}. |
246 | 251 | * <p>Default implementation sets {@linkplain SOAPMessage#setProperty(String, Object) message properties}, if any. |
|
0 commit comments