Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
28c2ec0d
Commit
28c2ec0d
authored
Jan 21, 2010
by
kenton@google.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some Java warnings. Patch from Evan Jones.
parent
48443683
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
16 additions
and
24 deletions
+16
-24
CONTRIBUTORS.txt
CONTRIBUTORS.txt
+1
-0
AbstractMessage.java
java/src/main/java/com/google/protobuf/AbstractMessage.java
+0
-1
AbstractMessageLite.java
...rc/main/java/com/google/protobuf/AbstractMessageLite.java
+1
-2
FieldSet.java
java/src/main/java/com/google/protobuf/FieldSet.java
+5
-5
GeneratedMessage.java
java/src/main/java/com/google/protobuf/GeneratedMessage.java
+2
-4
TextFormat.java
java/src/main/java/com/google/protobuf/TextFormat.java
+1
-2
CodedOutputStreamTest.java
.../test/java/com/google/protobuf/CodedOutputStreamTest.java
+0
-1
DescriptorsTest.java
java/src/test/java/com/google/protobuf/DescriptorsTest.java
+0
-1
ServiceTest.java
java/src/test/java/com/google/protobuf/ServiceTest.java
+0
-6
TextFormatTest.java
java/src/test/java/com/google/protobuf/TextFormatTest.java
+6
-2
No files found.
CONTRIBUTORS.txt
View file @
28c2ec0d
...
@@ -80,5 +80,6 @@ Patch contributors:
...
@@ -80,5 +80,6 @@ Patch contributors:
* Fixes for Solaris 10 32/64-bit confusion.
* Fixes for Solaris 10 32/64-bit confusion.
Evan Jones <evanj@mit.edu>
Evan Jones <evanj@mit.edu>
* Optimize Java serialization code when writing a small message to a stream.
* Optimize Java serialization code when writing a small message to a stream.
* Clean up some Java warnings.
Michael Kucharski <m.kucharski@gmail.com>
Michael Kucharski <m.kucharski@gmail.com>
* Added CodedInputStream.getTotalBytesRead().
* Added CodedInputStream.getTotalBytesRead().
java/src/main/java/com/google/protobuf/AbstractMessage.java
View file @
28c2ec0d
...
@@ -274,7 +274,6 @@ public abstract class AbstractMessage extends AbstractMessageLite
...
@@ -274,7 +274,6 @@ public abstract class AbstractMessage extends AbstractMessageLite
* @param tag The tag, which should have already been read.
* @param tag The tag, which should have already been read.
* @return {@code true} unless the tag is an end-group tag.
* @return {@code true} unless the tag is an end-group tag.
*/
*/
@SuppressWarnings
(
"unchecked"
)
static
boolean
mergeFieldFrom
(
static
boolean
mergeFieldFrom
(
final
CodedInputStream
input
,
final
CodedInputStream
input
,
final
UnknownFieldSet
.
Builder
unknownFields
,
final
UnknownFieldSet
.
Builder
unknownFields
,
...
...
java/src/main/java/com/google/protobuf/AbstractMessageLite.java
View file @
28c2ec0d
...
@@ -313,8 +313,7 @@ public abstract class AbstractMessageLite implements MessageLite {
...
@@ -313,8 +313,7 @@ public abstract class AbstractMessageLite implements MessageLite {
}
}
}
}
if
(
values
instanceof
Collection
)
{
if
(
values
instanceof
Collection
)
{
@SuppressWarnings
(
"unsafe"
)
final
final
Collection
<
T
>
collection
=
(
Collection
<
T
>)
values
;
Collection
<
T
>
collection
=
(
Collection
<
T
>)
values
;
list
.
addAll
(
collection
);
list
.
addAll
(
collection
);
}
else
{
}
else
{
for
(
final
T
value
:
values
)
{
for
(
final
T
value
:
values
)
{
...
...
java/src/main/java/com/google/protobuf/FieldSet.java
View file @
28c2ec0d
...
@@ -210,7 +210,7 @@ final class FieldSet<FieldDescriptorType extends
...
@@ -210,7 +210,7 @@ final class FieldSet<FieldDescriptorType extends
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
0
;
return
0
;
}
else
{
}
else
{
return
((
List
)
value
).
size
();
return
((
List
<?>
)
value
).
size
();
}
}
}
}
...
@@ -230,7 +230,7 @@ final class FieldSet<FieldDescriptorType extends
...
@@ -230,7 +230,7 @@ final class FieldSet<FieldDescriptorType extends
if
(
value
==
null
)
{
if
(
value
==
null
)
{
throw
new
IndexOutOfBoundsException
();
throw
new
IndexOutOfBoundsException
();
}
else
{
}
else
{
return
((
List
)
value
).
get
(
index
);
return
((
List
<?>
)
value
).
get
(
index
);
}
}
}
}
...
@@ -564,7 +564,7 @@ final class FieldSet<FieldDescriptorType extends
...
@@ -564,7 +564,7 @@ final class FieldSet<FieldDescriptorType extends
WireFormat
.
FieldType
type
=
descriptor
.
getLiteType
();
WireFormat
.
FieldType
type
=
descriptor
.
getLiteType
();
int
number
=
descriptor
.
getNumber
();
int
number
=
descriptor
.
getNumber
();
if
(
descriptor
.
isRepeated
())
{
if
(
descriptor
.
isRepeated
())
{
final
List
valueList
=
(
List
)
value
;
final
List
<?>
valueList
=
(
List
<?>
)
value
;
if
(
descriptor
.
isPacked
())
{
if
(
descriptor
.
isPacked
())
{
output
.
writeTag
(
number
,
WireFormat
.
WIRETYPE_LENGTH_DELIMITED
);
output
.
writeTag
(
number
,
WireFormat
.
WIRETYPE_LENGTH_DELIMITED
);
// Compute the total data size so the length can be written.
// Compute the total data size so the length can be written.
...
@@ -692,7 +692,7 @@ final class FieldSet<FieldDescriptorType extends
...
@@ -692,7 +692,7 @@ final class FieldSet<FieldDescriptorType extends
if
(
descriptor
.
isRepeated
())
{
if
(
descriptor
.
isRepeated
())
{
if
(
descriptor
.
isPacked
())
{
if
(
descriptor
.
isPacked
())
{
int
dataSize
=
0
;
int
dataSize
=
0
;
for
(
final
Object
element
:
(
List
)
value
)
{
for
(
final
Object
element
:
(
List
<?>
)
value
)
{
dataSize
+=
computeElementSizeNoTag
(
type
,
element
);
dataSize
+=
computeElementSizeNoTag
(
type
,
element
);
}
}
return
dataSize
+
return
dataSize
+
...
@@ -700,7 +700,7 @@ final class FieldSet<FieldDescriptorType extends
...
@@ -700,7 +700,7 @@ final class FieldSet<FieldDescriptorType extends
CodedOutputStream
.
computeRawVarint32Size
(
dataSize
);
CodedOutputStream
.
computeRawVarint32Size
(
dataSize
);
}
else
{
}
else
{
int
size
=
0
;
int
size
=
0
;
for
(
final
Object
element
:
(
List
)
value
)
{
for
(
final
Object
element
:
(
List
<?>
)
value
)
{
size
+=
computeElementSize
(
type
,
number
,
element
);
size
+=
computeElementSize
(
type
,
number
,
element
);
}
}
return
size
;
return
size
;
...
...
java/src/main/java/com/google/protobuf/GeneratedMessage.java
View file @
28c2ec0d
...
@@ -75,7 +75,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -75,7 +75,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
final
Descriptor
descriptor
=
internalGetFieldAccessorTable
().
descriptor
;
final
Descriptor
descriptor
=
internalGetFieldAccessorTable
().
descriptor
;
for
(
final
FieldDescriptor
field
:
descriptor
.
getFields
())
{
for
(
final
FieldDescriptor
field
:
descriptor
.
getFields
())
{
if
(
field
.
isRepeated
())
{
if
(
field
.
isRepeated
())
{
final
List
value
=
(
List
)
getField
(
field
);
final
List
<?>
value
=
(
List
<?>
)
getField
(
field
);
if
(!
value
.
isEmpty
())
{
if
(!
value
.
isEmpty
())
{
result
.
put
(
field
,
value
);
result
.
put
(
field
,
value
);
}
}
...
@@ -652,7 +652,6 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -652,7 +652,6 @@ public abstract class GeneratedMessage extends AbstractMessage {
final
UnknownFieldSet
.
Builder
unknownFields
,
final
UnknownFieldSet
.
Builder
unknownFields
,
final
ExtensionRegistryLite
extensionRegistry
,
final
ExtensionRegistryLite
extensionRegistry
,
final
int
tag
)
throws
IOException
{
final
int
tag
)
throws
IOException
{
final
ExtendableMessage
<
MessageType
>
message
=
internalGetResult
();
return
AbstractMessage
.
Builder
.
mergeFieldFrom
(
return
AbstractMessage
.
Builder
.
mergeFieldFrom
(
input
,
unknownFields
,
extensionRegistry
,
this
,
tag
);
input
,
unknownFields
,
extensionRegistry
,
this
,
tag
);
}
}
...
@@ -821,7 +820,6 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -821,7 +820,6 @@ public abstract class GeneratedMessage extends AbstractMessage {
* If the extension is an embedded message or group, returns the default
* If the extension is an embedded message or group, returns the default
* instance of the message.
* instance of the message.
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
Message
getMessageDefaultInstance
()
{
public
Message
getMessageDefaultInstance
()
{
return
messageDefaultInstance
;
return
messageDefaultInstance
;
}
}
...
@@ -1137,7 +1135,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -1137,7 +1135,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
// 2) Insures that the caller cannot modify the list later on and
// 2) Insures that the caller cannot modify the list later on and
// have the modifications be reflected in the message.
// have the modifications be reflected in the message.
clear
(
builder
);
clear
(
builder
);
for
(
final
Object
element
:
(
List
)
value
)
{
for
(
final
Object
element
:
(
List
<?>
)
value
)
{
addRepeated
(
builder
,
element
);
addRepeated
(
builder
,
element
);
}
}
}
}
...
...
java/src/main/java/com/google/protobuf/TextFormat.java
View file @
28c2ec0d
...
@@ -144,7 +144,7 @@ public final class TextFormat {
...
@@ -144,7 +144,7 @@ public final class TextFormat {
throws
IOException
{
throws
IOException
{
if
(
field
.
isRepeated
())
{
if
(
field
.
isRepeated
())
{
// Repeated field. Print each element.
// Repeated field. Print each element.
for
(
final
Object
element
:
(
List
)
value
)
{
for
(
final
Object
element
:
(
List
<?>
)
value
)
{
printSingleField
(
field
,
element
,
generator
);
printSingleField
(
field
,
element
,
generator
);
}
}
}
else
{
}
else
{
...
@@ -250,7 +250,6 @@ public final class TextFormat {
...
@@ -250,7 +250,6 @@ public final class TextFormat {
throws
IOException
{
throws
IOException
{
for
(
final
Map
.
Entry
<
Integer
,
UnknownFieldSet
.
Field
>
entry
:
for
(
final
Map
.
Entry
<
Integer
,
UnknownFieldSet
.
Field
>
entry
:
unknownFields
.
asMap
().
entrySet
())
{
unknownFields
.
asMap
().
entrySet
())
{
final
String
prefix
=
entry
.
getKey
().
toString
()
+
": "
;
final
UnknownFieldSet
.
Field
field
=
entry
.
getValue
();
final
UnknownFieldSet
.
Field
field
=
entry
.
getValue
();
for
(
final
long
value
:
field
.
getVarintList
())
{
for
(
final
long
value
:
field
.
getVarintList
())
{
...
...
java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java
View file @
28c2ec0d
...
@@ -37,7 +37,6 @@ import junit.framework.TestCase;
...
@@ -37,7 +37,6 @@ import junit.framework.TestCase;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
...
java/src/test/java/com/google/protobuf/DescriptorsTest.java
View file @
28c2ec0d
...
@@ -44,7 +44,6 @@ import com.google.protobuf.Descriptors.MethodDescriptor;
...
@@ -44,7 +44,6 @@ import com.google.protobuf.Descriptors.MethodDescriptor;
import
com.google.protobuf.test.UnittestImport
;
import
com.google.protobuf.test.UnittestImport
;
import
com.google.protobuf.test.UnittestImport.ImportEnum
;
import
com.google.protobuf.test.UnittestImport.ImportEnum
;
import
com.google.protobuf.test.UnittestImport.ImportMessage
;
import
protobuf_unittest.UnittestProto
;
import
protobuf_unittest.UnittestProto
;
import
protobuf_unittest.UnittestProto.ForeignEnum
;
import
protobuf_unittest.UnittestProto.ForeignEnum
;
import
protobuf_unittest.UnittestProto.ForeignMessage
;
import
protobuf_unittest.UnittestProto.ForeignMessage
;
...
...
java/src/test/java/com/google/protobuf/ServiceTest.java
View file @
28c2ec0d
...
@@ -205,12 +205,6 @@ public class ServiceTest extends TestCase {
...
@@ -205,12 +205,6 @@ public class ServiceTest extends TestCase {
MethodDescriptor
fooMethod
=
MethodDescriptor
fooMethod
=
ServiceWithNoOuter
.
getDescriptor
().
findMethodByName
(
"Foo"
);
ServiceWithNoOuter
.
getDescriptor
().
findMethodByName
(
"Foo"
);
MessageWithNoOuter
request
=
MessageWithNoOuter
.
getDefaultInstance
();
MessageWithNoOuter
request
=
MessageWithNoOuter
.
getDefaultInstance
();
RpcCallback
<
Message
>
callback
=
new
RpcCallback
<
Message
>()
{
public
void
run
(
Message
parameter
)
{
// No reason this should be run.
fail
();
}
};
TestAllTypes
expectedResponse
=
TestAllTypes
.
getDefaultInstance
();
TestAllTypes
expectedResponse
=
TestAllTypes
.
getDefaultInstance
();
EasyMock
.
expect
(
impl
.
foo
(
EasyMock
.
same
(
controller
),
EasyMock
.
same
(
request
)))
EasyMock
.
expect
(
impl
.
foo
(
EasyMock
.
same
(
controller
),
EasyMock
.
same
(
request
)))
...
...
java/src/test/java/com/google/protobuf/TextFormatTest.java
View file @
28c2ec0d
...
@@ -60,8 +60,8 @@ public class TextFormatTest extends TestCase {
...
@@ -60,8 +60,8 @@ public class TextFormatTest extends TestCase {
// A representation of the above string with all the characters escaped.
// A representation of the above string with all the characters escaped.
private
final
static
String
kEscapeTestStringEscaped
=
private
final
static
String
kEscapeTestStringEscaped
=
"\
"\
\\"A string with \\' characters \\n and \\r newlines "
"\\\"A string with \\' characters \\n and \\r newlines "
+
"and \\t tabs and \\001 slashes \\\\
\"
"
;
+
"and \\t tabs and \\001 slashes \\\\"
;
private
static
String
allFieldsSetText
=
TestUtil
.
readTextFromFile
(
private
static
String
allFieldsSetText
=
TestUtil
.
readTextFromFile
(
"text_format_unittest_data.txt"
);
"text_format_unittest_data.txt"
);
...
@@ -469,6 +469,10 @@ public class TextFormatTest extends TestCase {
...
@@ -469,6 +469,10 @@ public class TextFormatTest extends TestCase {
TextFormat
.
unescapeBytes
(
"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""
));
TextFormat
.
unescapeBytes
(
"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""
));
assertEquals
(
"\0\001\007\b\f\n\r\t\013\\\'\""
,
assertEquals
(
"\0\001\007\b\f\n\r\t\013\\\'\""
,
TextFormat
.
unescapeText
(
"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""
));
TextFormat
.
unescapeText
(
"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""
));
assertEquals
(
kEscapeTestStringEscaped
,
TextFormat
.
escapeText
(
kEscapeTestString
));
assertEquals
(
kEscapeTestString
,
TextFormat
.
unescapeText
(
kEscapeTestStringEscaped
));
// Unicode handling.
// Unicode handling.
assertEquals
(
"\\341\\210\\264"
,
TextFormat
.
escapeText
(
"\u1234"
));
assertEquals
(
"\\341\\210\\264"
,
TextFormat
.
escapeText
(
"\u1234"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment