This repository was archived by the owner on Dec 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +19
-20
lines changed
core_native/java/com/google/census
javatests/com/google/census
examples/java/com/google/census Expand file tree Collapse file tree 5 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ public MetricMap build() {
107107 return new MetricMap (metrics );
108108 }
109109
110- private ArrayList <Metric > metrics = new ArrayList <Metric >();
110+ private final ArrayList <Metric > metrics = new ArrayList <Metric >();
111111
112112 private Builder () {
113113 }
Original file line number Diff line number Diff line change 1313
1414package com .google .census ;
1515
16+ import java .lang .reflect .InvocationTargetException ;
17+
1618/**
1719 * Census-specific service provider mechanism.
1820 *
@@ -40,14 +42,20 @@ class Provider<T> {
4042 T newInstance () {
4143 try {
4244 if (provider != null ) {
43- return (T ) provider .newInstance ();
45+ return (T ) provider .getConstructor (). newInstance ();
4446 }
4547 } catch (InstantiationException e ) {
4648 // TODO(dpo): decide what to do here - log, crash, or both.
4749 System .err .println (e );
4850 } catch (IllegalAccessException e ) {
4951 // TODO(dpo): decide what to do here - log, crash, or both.
5052 System .err .println (e );
53+ } catch (NoSuchMethodException e ) {
54+ // TODO(dpo): decide what to do here - log, crash, or both.
55+ System .err .println (e );
56+ } catch (InvocationTargetException e ) {
57+ // TODO(dpo): decide what to do here - log, crash, or both.
58+ System .err .println (e );
5159 }
5260 return null ;
5361 }
Original file line number Diff line number Diff line change @@ -38,15 +38,9 @@ public void testGetValue() {
3838 assertThat (new Tag ("key" , "val" ).getValue ()).isEqualTo ("val" );
3939 }
4040
41- @ Test
41+ @ Test ( expected = UnsupportedOperationException . class )
4242 public void testSetValue () {
43- boolean fail = true ;
44- try {
45- new Tag ("key" , "val" ).setValue ("val1" );
46- fail = false ;
47- } catch (UnsupportedOperationException expected ) {
48- }
49- assertThat (fail ).isTrue ();
43+ new Tag ("key" , "val" ).setValue ("val1" );
5044 }
5145
5246 @ Test
Original file line number Diff line number Diff line change 2121final class CensusContextFactoryImpl extends CensusContextFactory {
2222 static final CensusContextImpl DEFAULT = new CensusContextImpl (new HashMap <String , String >(0 ));
2323
24+ public CensusContextFactoryImpl () {}
25+
2426 /**
2527 * Deserializes a {@link CensusContextImpl} from a serialized {@code CensusContextProto}.
2628 *
Original file line number Diff line number Diff line change 1111 * limitations under the License.
1212 */
1313
14- package com .google .census .examples ;
15-
16- import com .google .census .Census ;
17- import com .google .census .CensusContext ;
18- import com .google .census .CensusGrpcContext ;
19- import com .google .census .MetricMap ;
20- import com .google .census .MetricName ;
21- import com .google .census .TagKey ;
22- import com .google .census .TagValue ;
14+ package com .google .census ;
2315
2416import io .grpc .Context ;
2517
18+ /**
19+ * Simple program that uses Census contexts.
20+ */
2621public class CensusRunner {
2722 private static final TagKey K1 = new TagKey ("k1" );
2823 private static final TagKey K2 = new TagKey ("k2" );
@@ -37,7 +32,7 @@ public class CensusRunner {
3732 private static final MetricName M1 = new MetricName ("m1" );
3833 private static final MetricName M2 = new MetricName ("m2" );
3934
40- public static void main (String args [] ) {
35+ public static void main (String [] args ) {
4136 System .out .println ("Hello Census World" );
4237 System .out .println ("Default Tags: " + DEFAULT );
4338 System .out .println ("Current Tags: " + getCurrentCensusContext ());
You can’t perform that action at this time.
0 commit comments