递归是一种"分而治之"的风格,它在变小(树数据结构)时分裂,我希望它在发现违规时完全破坏,意味着打破所有递归路径,并返回true.这可能吗?
我试着写一个测试来验证我们的CORS设置.我这样配置CORS.
@Override
public void configure(HttpSecurity httpSecurity) throws Exception {
// super.configure(httpSecurity);
httpSecurity.csrf().disable();
httpSecurity.authorizeRequests().antMatchers("/**").permitAll();
httpSecurity.cors();
}
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
List<String> allowedMethods = CORS_ALLOWED_METHODS;
configuration.setAllowedMethods(allowedMethods);
configuration.setAllowedOrigins(CORS_ALLOWED_ORIGINS);
configuration.setAllowedHeaders(CORS_ALLOWED_HEADERS);
configuration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
Run Code Online (Sandbox Code Playgroud)
我已经使用调试器验证了CORS_ALLOWED_METHODS我的测试运行时的值.
这是我的测试.当我在标题上断言时它失败了.
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("dev")
public class ControllerTests {
@Autowired
private WebApplicationContext wac;
public MockMvc mockMvc;
@Before
public void setup() {
DefaultMockMvcBuilder builder = MockMvcBuilders
.webAppContextSetup(this.wac)
.apply(SecurityMockMvcConfigurers.springSecurity())
.dispatchOptions(true);
this.mockMvc = builder.build();
}
@Test
public void …Run Code Online (Sandbox Code Playgroud) 当我使用apt-get安装或升级我的Ubuntu hardy系统时,我经常收到这样的消息:
$ sudo apt-get install foo
Reading package lists... Done
Segmentation faulty tree... 50%
$ sudo apt-get install foo
Reading package lists... Done
Building dependency tree
Reading state information... Done
Segmentation fault
$ sudo apt-get install foo
Reading package lists... Done
Building dependency tree
Reading state information... Done
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Aborted
cc -Os -g -Wall -DLOCAL_ROOT=\"/usr/share/polipo/www/\" -DDISK_CACHE_ROOT=\"/var/cache/polipo/\" -DCHUNK_SIZE=16384 -c -o http_parse.o http_parse.c
http_parse.c:1564: internal compiler error: Segmentation fault …Run Code Online (Sandbox Code Playgroud) 我有一个Module提供List<String>使用@Provides注释方法的Guice .
class TestModule() : Module {
override fun configure(binder: Binder) {}
@Provides fun getStrings(): List<String> = listOf("foo", "bar")
}
class Test {
@Test fun `provider can not deliver`() {
val injector = Guice.createInjector(TestModule())
injector.getInstance(object : Key<List<String>>() {})
}
}
Run Code Online (Sandbox Code Playgroud)
但是,测试失败了:
1) No implementation for java.util.List<? extends java.lang.String> was bound.
while locating java.util.List<? extends java.lang.String>
Run Code Online (Sandbox Code Playgroud)
现在,这似乎与这个问题相同,但我不知道在哪里添加@JvmSuppressWildcards注释; 将它添加到getStrings()方法不会改变任何东西,因为它增加了object在getInstance()呼叫.我如何让Guice做我想做的事?
所以,我和Kibana有这个问题,我不知道如何解决.我将从描述环境开始:
现在,当运行更复杂的查询时,Kibana在通过ELB访问时,会在两到三分钟后显示"网关超时"错误消息.Chrome中的网络控制台显示正在触发两个请求,第一个是确定请求的时间跨度的索引,第二个是结果数据的索引.第一个请求需要20到50秒才能成功,第二个请求总是在两分钟后完成504(网关超时).
当Kibana直接针对其中一个Elasticsearch节点运行查询时,查询大约需要7分钟并成功完成.
当没有ELB直接针对其中一个Kibana实例(使用curl)运行查询时,它在几乎两分钟后也会失败.使用Wireshark,我可以看到Kibana在120秒后关闭HTTP连接.
超时来自哪里?我怎么摆脱它?
我有一个在Java中声明的静态方法:
class X {
public static void foo(Y y) { … }
}
Run Code Online (Sandbox Code Playgroud)
我希望使用此方法作为YKotlin 中类型实例的扩展方法:
import X.foo
…
y.foo()
Run Code Online (Sandbox Code Playgroud)
那可能吗?我可以控制所有相关的源代码,例如添加注释.
检查给定字符串中所有字母的最佳逻辑是什么.
如果提供的字符串中有26个字母都可用,我想检查并执行操作.例如.用五十个酒壶包装我的盒子.
顺便说一句,我的代码将是Java.
在Java中,我有以下方法:
public Optional<Foo> getFoo() {
// always return some non-null value
}
Run Code Online (Sandbox Code Playgroud)
在Kotlin代码中,此方法的返回类型为Optional<Foo!>!。通过使用@Nonnull注释,我可以将其缩减为Optional<Foo!>(即,仅Foo不再对类型进行空检查)。
有没有办法注释使Kotlin编译器对返回值正确进行null检查的方法?
java ×3
kotlin ×3
algorithm ×1
annotations ×1
apt ×1
cors ×1
guice ×1
kibana ×1
logic ×1
non-nullable ×1
recursion ×1
spring-boot ×1
spring-mvc ×1
testing ×1
ubuntu ×1